@yeaft/webchat-agent 1.0.299 → 1.0.301
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/context.js +1 -0
- package/index.js +9 -0
- package/local-runtime/server/database.js +1 -0
- package/local-runtime/server/db/connection.js +86 -0
- package/local-runtime/server/db/yeaft-project-db.js +225 -0
- package/local-runtime/server/handlers/agent-output.js +41 -5
- package/local-runtime/server/handlers/client-conversation.js +73 -0
- package/local-runtime/server/ws-utils.js +5 -1
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +73 -78
- 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
- package/yeaft/cli-session-runner.js +3 -2
- package/yeaft/cli.js +20 -1
- package/yeaft/conversation/search.js +13 -7
- package/yeaft/engine.js +29 -5
- package/yeaft/managed-cli.js +618 -0
- package/yeaft/session.js +7 -0
- package/yeaft/sub-agent/runner.js +6 -0
- package/yeaft/tools/disk-usage.js +243 -0
- package/yeaft/tools/glob.js +84 -28
- package/yeaft/tools/grep.js +616 -152
- package/yeaft/tools/history-search.js +12 -3
- package/yeaft/tools/index.js +2 -0
- package/yeaft/tools/process-runner.js +211 -0
- package/yeaft/tools/search-paths.js +108 -0
- package/yeaft/tools/types.js +2 -0
- package/yeaft/web-bridge.js +93 -6
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var F=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var cm=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function yl(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 bl(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 wl(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function at(e){return nacl.util.decodeBase64(e)}var gr=F(()=>{});function Ct(){return globalThis.localStorage||null}function Sl(){let e=hr();for(let t of ro)try{t(e)}catch{}}function dm(){try{Ct()?.removeItem(pn),Ct()?.removeItem(fn)}catch{}}function um(e){return String(e||"").trim()||null}function kl(e,t){if(!gn(t))return{};try{let s=JSON.parse(Ct()?.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)?(Ct()?.removeItem(e),{}):s.records}catch{try{Ct()?.removeItem(e)}catch{}return{}}}function Il(e,t,s){if(!gn(s))return!1;try{return Ct()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function lt(e){let t=um(e);if(!t)return io(),null;if(es!==t){es=t,mr+=1;for(let s of[pn,fn])try{let n=JSON.parse(Ct()?.getItem(s)||"null");(!n||n.ownerId!==t)&&Ct()?.removeItem(s)}catch{try{Ct()?.removeItem(s)}catch{}}Sl()}return hr()}function io(){es=null,mr+=1,dm(),Sl()}function hr(){return es?{ownerId:es,epoch:mr}:null}function gn(e){return!!e&&!!es&&e.ownerId===es&&e.epoch===mr}function Cl(e){return{drafts:kl(pn,e),outbox:kl(fn,e)}}function oo(e,t){return Il(pn,e,t)}function mn(e,t){return Il(fn,e,t)}function Al(e){return typeof e!="function"?()=>{}:(ro.add(e),()=>ro.delete(e))}var pn,fn,es,mr,ro,zy,ao=F(()=>{pn="yeaft-work-center-composer-drafts-v1",fn="yeaft-work-center-message-outbox-v1",es=null,mr=0,ro=new Set;zy=Object.freeze({drafts:pn,outbox:fn})});var pm,fm,_e,ct=F(()=>{gr();ao();({defineStore:pm}=Pinia),fm=1800*1e3,_e=pm("auth",{state:()=>({skipAuth:!1,emailVerification:!1,passwordResetEnabled:!1,totpEnabled:!1,registrationEnabled:!1,aadEnabled:!1,aadClientId:null,aadTenantId:null,ssoProviders:{github:!1,google:!1,wechat:!1,alipay:!1},linkedIdentities:[],hasPassword:!1,identitiesLoading:!1,identitiesError:null,initialized:!1,authGeneration:0,isAuthenticated:!1,token:null,sessionKey:null,userId:null,role:null,loginStep:"credentials",tempToken:null,emailHint:null,setupToken:null,totpSecret:null,qrCode:null,error:null,loading:!1,qrPanel:null,_qrPollTimer:null,_sessionRefreshTimer:null,_sessionRefreshVisibilityHandler:null}),actions:{async initialize(){if(this.initialized)return this.isAuthenticated;try{if(await this.checkAuthMode(),this.skipAuth&&this.isAuthenticated)return!0;let e=!1;return typeof window<"u"&&typeof this.consumeSsoRedirect=="function"&&(e=this.consumeSsoRedirect()),!this.isAuthenticated&&!e&&await this.restoreSession(),this.isAuthenticated}finally{this.initialized=!0}},async checkAuthMode(){try{let t=await(await fetch("/api/auth/mode")).json();this.skipAuth=t.skipAuth,this.emailVerification=t.emailVerification,this.passwordResetEnabled=!!t.passwordResetEnabled,this.totpEnabled=t.totpEnabled,this.registrationEnabled=t.registrationEnabled||!1,this.aadEnabled=t.aadEnabled||!1,this.aadClientId=t.aadClientId||null,this.aadTenantId=t.aadTenantId||null,this.ssoProviders=Object.assign({github:!1,google:!1,wechat:!1,alipay:!1},t.ssoProviders||{}),this.skipAuth&&(this.userId="skip-auth",lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated")}catch{}},async login(e,t){this.loading=!0,this.error=null;try{let n=await(await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})})).json();return n.success?n.needTotpSetup?(this.setupToken=n.setupToken,this.totpSecret=n.totpSecret,this.qrCode=n.qrCode,this.loginStep="totp-setup",!0):n.needTotpCode?(this.tempToken=n.tempToken,this.loginStep="totp",!0):n.needEmailCode?(this.tempToken=n.tempToken,this.emailHint=n.emailHint,this.loginStep="verification",!0):(this.token=n.token,this.sessionKey=n.sessionKey?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),!0):(this.error=n.error||"Login failed",!1)}catch(s){return this.error=s.message||"Network error",!1}finally{this.loading=!1}},async loginWithMicrosoft(){if(!this.aadEnabled||!this.aadClientId||!this.aadTenantId)return this.error="Microsoft login is not configured",!1;if(typeof msal>"u"||!msal.PublicClientApplication)return this.error="Microsoft authentication library not loaded",!1;this.loading=!0,this.error=null;try{let e={auth:{clientId:this.aadClientId,authority:`https://login.microsoftonline.com/${this.aadTenantId}`,redirectUri:window.location.origin+"/auth/callback"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1}},t=new msal.PublicClientApplication(e);await t.initialize();let s=await t.loginPopup({scopes:["openid","profile","email"]});if(!s||!s.idToken)return this.error="Microsoft login failed: no token received",!1;let r=await(await fetch("/api/auth/aad",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:s.idToken})})).json();return r.success?(this.token=r.token,this.sessionKey=r.sessionKey?at(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",r.token),this.startSessionRefresh(),!0):(this.error=r.error||"Microsoft login failed",!1)}catch(e){return e.errorCode==="user_cancelled"||e.name==="BrowserAuthError"?(this.error=null,!1):(this.error=e.message||"Microsoft login failed",!1)}finally{this.loading=!1}},async verifyTotpCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,totpCode:e})})).json();return s.success?s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"TOTP verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async completeTotpSetup(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/setup-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({setupToken:this.setupToken,totpCode:e})})).json();return s.success?(this.setupToken=null,this.totpSecret=null,this.qrCode=null,s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0)):(this.error=s.error||"TOTP setup failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async verifyCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,code:e})})).json();return s.success?(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,this.emailHint=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"Verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async register(e,t,s,n){this.loading=!0,this.error=null;try{let i=await(await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:s||void 0,invitationCode:n})})).json();return i.success?!0:(this.error=i.error||"Registration failed",!1)}catch(r){return this.error=r.message||"Network error",!1}finally{this.loading=!1}},showRegister(){this.loginStep="register",this.error=null},loginWithSso(e){window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start`},async loginWithAlipayMobile({intent:e="login"}={}){if(!await this.startSsoQr("alipay",{intent:e}))return!1;let s=this.qrPanel?.authorizeUrl;if(!s)return!1;let n=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(s)}`;return this.qrPanel={...this.qrPanel,mobileDeepLink:!0},window.location.href=n,!0},async startSsoQr(e,{intent:t="login"}={}){this.cancelSsoQr(),this.error=null;try{let s=new URLSearchParams;if(t==="bind"){if(!this.isAuthenticated)return this.error="You must be logged in to bind an identity",!1;s.set("intent","bind")}let n=s.toString(),r=`/api/auth/sso/${encodeURIComponent(e)}/start-qr${n?"?"+n:""}`,i=await fetch(r),o=await i.json();return!i.ok||!o.success?(this.error=o.error||"Failed to start QR login",!1):(this.qrPanel={provider:e,intent:t,authorizeUrl:o.authorizeUrl,state:o.state,status:"pending",error:null},this._startQrPoll(),!0)}catch(s){return this.error=s.message||"Network error",!1}},_startQrPoll(){this._stopQrPollTimer();let e=async()=>{if(!this.qrPanel)return;let t=this.qrPanel.state;try{let n=await(await fetch(`/api/auth/sso/poll/${encodeURIComponent(t)}`)).json();if(!this.qrPanel||this.qrPanel.state!==t||n.status==="pending")return;if(n.status==="login"){this.token=n.token,this.sessionKey=n.sessionKey?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),this.cancelSsoQr();return}if(n.status==="bind"){this.qrPanel={...this.qrPanel,status:"bound"},this._stopQrPollTimer();return}this.qrPanel={...this.qrPanel,status:"error",error:n.error||"SSO failed"},this._stopQrPollTimer()}catch{}};this._qrPollTick=e,this._qrPollTimer=setInterval(e,2e3),typeof document<"u"&&!this._qrVisHandler&&(this._qrVisHandler=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||!this.qrPanel||!this._qrPollTick||(this._qrPollTick(),this._qrPollTimer&&clearInterval(this._qrPollTimer),this._qrPollTimer=setInterval(this._qrPollTick,2e3))},document.addEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.addEventListener("pageshow",this._qrVisHandler))},_stopQrPollTimer(){this._qrPollTimer&&(clearInterval(this._qrPollTimer),this._qrPollTimer=null),this._qrVisHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._qrVisHandler),this._qrVisHandler=null),this._qrPollTick=null},cancelSsoQr(){this._stopQrPollTimer(),this.qrPanel=null},bindSso(e){if(!this.isAuthenticated){this.error="You must be logged in to bind an identity";return}let t=new URLSearchParams({intent:"bind"});window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start?${t.toString()}`},consumeSsoRedirect(){let e=window.location.hash||"",t=e.indexOf("?");if(!e.startsWith("#/sso-complete")||t<0)return!1;let s=new URLSearchParams(e.slice(t+1)),n=s.get("token"),r=s.get("sessionKey"),i=s.get("role"),o=s.get("userId");if(!n)return!1;this.token=n,this.sessionKey=r?at(r):null,this.role=i||"pro",this.userId=o||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");return i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role),this.userId=r?.userId||null,lt(this.userId),!0}catch{return!1}},startSessionRefresh(){if(this.stopSessionRefresh(),!this.isAuthenticated||this.skipAuth)return;let e=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||this.refreshSession()};this._sessionRefreshTimer=setInterval(e,fm),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}this.clearStoredSession()},clearStoredSession(e=null){this.reset(),localStorage.removeItem("authToken"),e&&(this.error=e)},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.startSessionRefresh(),!0}catch(n){return this.error=n.message||"Failed to restore session",!1}},setSessionKey(e){e&&(this.sessionKey=at(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){io(),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=At?.value||"zh-CN",r=(Ps[s]||Ps["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(Ps["zh-CN"]||{})[e]),r===void 0)return e;if(t)for(let[i,o]of Object.entries(t))r=r.replace(new RegExp(`\\{${i}\\}`,"g"),o);return r}function gm(){return At?.value||"zh-CN"}function hn(e){Ps[e]&&(At&&(At.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function mm(){let e=localStorage.getItem("locale");return e&&Ps[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function xl(e,t){return Ps=t,At=Vue.ref(mm()),document.documentElement.setAttribute("lang",At.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=At,e.provide("t",Ee),e.provide("locale",At),{t:Ee,setLocale:hn,getLocale:gm,locale:At}}var At,Ps,xt=F(()=>{At=null,Ps={}});function vr(e){if(e==null||e==="")return"claude-code";if(hm.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Rs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function yr(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 lo(e,t){let s=e.sessionCatalog.map(n=>({...n}));return e.sessionCatalogMutationRequests[t]={previousCatalog:s},s}function Tl(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog),!0):!1}function Ml(e,t,s="recent",n=null){let r=Rs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Pl(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 hm,co=F(()=>{hm=new Set(["claude-code","copilot"])});function _s(e,t,s=""){vn&&(clearTimeout(vn),vn=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(vn=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),vn=null},vm))}function gt(e){_s(e,!1)}function Rl(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:vr(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function _l(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:vr(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function El(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Dl(e,t){let s=e.conversations.find(n=>n.id===t);s&&(e.activeConversations=[t],e.currentWorkDir=s.workDir,e.messagesMap[t]?.length>0||(s.claudeSessionId?(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory")),e.sendWsMessage({type:"resume_conversation",agentId:s.agentId||e.currentAgent,claudeSessionId:s.claudeSessionId,workDir:s.workDir,conversationId:t})):(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5}))),e.sendWsMessage({type:"select_conversation",conversationId:t}))}function Ll(e){if(e.panels.length>0)return;let t=localStorage.getItem("panels");if(!t)return;let s;try{s=JSON.parse(t)}catch{localStorage.removeItem("panels");return}if(!Array.isArray(s)||s.length<2){localStorage.removeItem("panels");return}let n=new Set(e.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({id:i.id,conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null,activeRightPanel:i.activeRightPanel||null}));if(r.length<2){localStorage.removeItem("panels");return}e.panels=r,e.activePanelId=r[0]?.id||null;for(let i of r)i.conversationId&&(e.activeConversations.includes(i.conversationId)||e.activeConversations.push(i.conversationId),e.messagesMap[i.conversationId]||(e.messagesMap[i.conversationId]=[]),e.messagesMap[i.conversationId].length||e.requestChatHistory?.(i.conversationId,{mode:"recent",turns:5}))}function Es(e){if(e.currentAgent){if(localStorage.setItem("lastUsedAgent",e.currentAgent),localStorage.setItem("lastViewedConversation",e.currentConversation||""),e.lastViewedConversation=e.currentConversation,e.currentConversation){let t=e.conversations.find(s=>s.id===e.currentConversation);if(t?.claudeSessionId&&t?.workDir){let s=vr(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Rs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function $l(e){return e.lastUsedSession}function Vl(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 Fl(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 Ol(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 Hl(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 ql(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 Nl(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 Bl(e,t=20){if(_e().isAuthenticated){e.globalSessionsLoading=!0;try{let n=await fetch(`/api/sessions?limit=${t}`);if(n.ok){let r=await n.json();e.globalSessions=r.sessions||[]}}catch{}finally{e.globalSessionsLoading=!1}}}async function Wl(e,t){if(!_e().isAuthenticated)return!1;try{if((await fetch(`/api/sessions/${t}`,{method:"DELETE"})).ok)return e.globalSessions=e.globalSessions.filter(r=>r.id!==t),!0}catch{}return!1}function uo(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 Ul(e,t){let s=uo(e,t);return s&&s.online}var vm,vn,ts=F(()=>{ct();xt();co();vm=3e4,vn=null});function jl(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function zl(e){let t=yn;yn=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Kl(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&bm.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=yl(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function bn(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{yn=yn.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);yn.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Yl(e,t){try{let s=JSON.parse(t);return e.sessionKey&&wl(s)?bl(s,e.sessionKey):s}catch{return null}}function Gl(e){let t=_e(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(e.ws.onopen=null,e.ws.onmessage=null,e.ws.onclose=null,e.ws.close(),e.ws=null),e.connectionState=e.reconnectAttempts>0?"reconnecting":"connecting",e.serverEncryptionRequired=!0,e.chatHistoryRequestIdSupported=null,e.chatHistoryConnectionGeneration=Number(e.chatHistoryConnectionGeneration||0)+1;for(let[l,c]of Object.entries(e.chatHistoryRequests||{}))c?.loading&&(e.chatHistoryRequests[l]={...c,loading:!1,cancelled:!0,error:"connection_changed"});let i=Object.values(e.sessionCatalogMutationRequests||{});i.length>0&&(e.sessionCatalog=i[0].previousCatalog,e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let o=`${s}//${location.host}?type=web`;n&&(o+=`&token=${encodeURIComponent(n)}`);let a=new WebSocket(o);e.ws=a,a.onopen=()=>{if(a===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{a.send(JSON.stringify({type:"client_hello",plaintextOk:!0}))}catch{}zl(!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){jl(l)&&t.handleAuthFailure?.(void 0,n,r);return}e.authenticated=!1,clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e.pendingAgentSelection=null,e.agentSwitching=!1;let c=e.connectionState==="updating";if(e.connectionState=c?"updating":"disconnected",e.stopHeartbeat(),gt(e),jl(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,zl(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Ql(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 Xl(e){e.reconnectAttempts=0,e.connect()}function Zl(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 Jl(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function ec(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 yn,bm,po=F(()=>{ct();gr();ts();yn=[];bm=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Sm(e){return e?.type==="tool-use"}function fo(e){return e?.type==="tool-summary"}function go(e){return Sm(e)&&!km.has(e.toolName)}function nc(e,t,s,n=s){let r=t==="history"&&(n?.dbMessageId||n?.id)||null;return{...r?{id:`tool_summary_${t}_${r}`,dbMessageId:n?.dbMessageId||null}:{},type:"tool-summary",count:e,omittedCount:e,source:t,isHistory:t!=="live",timestamp:s?.timestamp||s?.startTime||n?.timestamp||n?.startTime||null,sessionId:s?.sessionId??s?.groupId??null,turnId:s?.turnId||null,vpId:s?.vpId||null,speakerVpId:s?.speakerVpId||null}}function Im(e,t){return!fo(e)||!fo(t)?!1:(e.turnId||null)===(t.turnId||null)&&(e.sessionId||null)===(t.sessionId||null)&&(e.speakerVpId||e.vpId||null)===(t.speakerVpId||t.vpId||null)&&(e.source||null)===(t.source||null)}function Cm(e,t){let s=(Number(e.count)||0)+(Number(t.count)||0);return e.count=s,e.omittedCount=s,!e.timestamp&&t.timestamp&&(e.timestamp=t.timestamp),Number(t.dbMessageId||0)>Number(e.dbMessageId||0)&&(e.dbMessageId=t.dbMessageId,t.id&&(e.id=t.id)),e}function tc(e){return[e?.sessionId||"",e?.turnId||"",e?.speakerVpId||e?.vpId||""].join("")}function sc(e,t,s,n,r=n){if(!t)return;let i=nc(t,s,n,r),o=e[e.length-1];Im(o,i)?Cm(o,i):e.push(i)}function mo(e=[]){let t=[],s=0,n=null,r=null;for(let i of e){if(go(i)&&i.isHistory){s+=1,n||(n=i),r=i;continue}sc(t,s,"history",n,r),s=0,n=null,r=null,t.push(i)}return sc(t,s,"history",n,r),t}function rc(e=[],t={}){let s=Number.isFinite(t.maxDetailed)?Math.max(1,t.maxDetailed):100;if(!Array.isArray(e)||e.length<=s)return e;let n=e.length;for(let p=e.length-1;p>=0;p-=1){let g=e[p];if(g?.type==="user"||g?.type==="system"||g?.type==="error")break;n=p}let r=e.slice(n),i=new Map;for(let p of r){if(!go(p)||p.isHistory)continue;let g=tc(p);i.set(g,(i.get(g)||0)+1)}let o=new Map;for(let[p,g]of i)g>s&&o.set(p,g-s);if(o.size===0)return e;let a=new Map,l=new Map,c=new Set,d=[],u=(p,g,b)=>{a.set(p,(a.get(p)||0)+g),!l.has(p)&&b&&l.set(p,b)},f=(p,g)=>{if(c.has(p))return;let b=a.get(p)||0;b<=0||(d.push(nc(b,"live",l.get(p)||g)),c.add(p))};for(let p of r){let g=tc(p);if(fo(p)&&p.source==="live"&&o.has(g)){u(g,Number(p.count)||0,p);continue}if(go(p)&&!p.isHistory&&o.has(g)){let b=o.get(g)||0;if(b>0){o.set(g,b-1),u(g,1,p);continue}}f(g,p),d.push(p)}for(let p of a.keys())f(p,l.get(p));return e.splice(n,e.length-n,...d),e}var km,ho=F(()=>{km=new Set(["TodoWrite","AskUserQuestion"])});function vo(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function wn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||vo(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 xm(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 br(e){let t=e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function yo(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}return e}function ic(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=br(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){yo(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);yo(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 oc(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function ac(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function bo({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function Tm(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"&&br(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,wn(e,t,o),!0):!1}function wr(e,t,s){if(!t)return;let n={...s,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:xm(s)};vo(e,t)&&!n.sessionId&&(n.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Am),vo(e,t)&&(!n.vpId&&e._currentYeaftVpId&&(n.vpId=e._currentYeaftVpId),!n.turnId&&e._currentYeaftTurnId&&(n.turnId=e._currentYeaftTurnId),wn(e,t,n)),e.messagesMap[t]||(e.messagesMap[t]=[]);let r=br(s);if(r){let i=e.messagesMap[t].find(o=>br(o)===r);if(i)return yo(i,n),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),i}return e.messagesMap[t].push(n),rc(e.messagesMap[t]),t===e.yeaftConversationId&&e.messagesMap[t].sort((i,o)=>i.timestamp-o.timestamp),n}function lc(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(Tm(e,t,n,s))return;let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(wn(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}wr(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(wn(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 wr(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 cc(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())),wn(e,t,o),o.type==="user")break}}function dc(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 uc(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 ss(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 pc(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function fc(e){return e?e.message_type==="tool_use"&&!Mm.has(e.tool_name)?{...pc(e),type:"tool-use",toolName:e.tool_name||"unknown",hasResult:!0,isHistory:!0,startTime:e.created_at||0}:wo(e):null}function wo(e){if(!e)return null;let t=pc(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 Am,Mm,Ds=F(()=>{ho();Am="grp_default";Mm=new Set(["TodoWrite","AskUserQuestion"])});function ns(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Ls(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={});let s=()=>{if(!e.processingConversations[t])return;let r=e.conversations.find(o=>o.id===t);e.sendWsMessage({type:"ping_session",conversationId:t,agentId:r?.agentId});let i=setTimeout(()=>{e.processingConversations[t]&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[t]={status:"agent-offline"})},1e4);e._pongTimeouts||(e._pongTimeouts={}),e._pongTimeouts[t]=i},n=setTimeout(()=>{e.processingConversations[t]&&(s(),e._processingWatchdogs[t]=setInterval(()=>{if(!e.processingConversations[t]){Ae(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function kr(e,t){e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?kn(e,t):Ls(e,t))}function Ae(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t)}function gc(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){let s=e.conversations.find(n=>n.id===t);e.sendWsMessage({type:"refresh_conversation",conversationId:t,agentId:s?.agentId}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},1e4)}},9e4)}function kn(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Nt=F(()=>{});function ko(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function $s(e,t,s){return!t||!s?!1:ko(e,t).includes(s)}function So(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function mc(e,t,s){if(!t||!s)return null;let n=So(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 Sn(e,t,s,n=null){if(!t||!s)return;let r=ko(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=So(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 Io(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=ko(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...So(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Sr=F(()=>{});function _m(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),e.messagesMap[s]=ic(r,n).sort((i,o)=>(i.timestamp||0)-(o.timestamp||0))}function Em(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 Ir(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Vs(e,t,s,{removeSource:n}){Ir(e,t)&&(Ir(e,s)||(e[s]=n?e[t]:Em(e[t])),n&&delete e[t])}function mt(e,t,s=null){if(!t)return null;let n=e?._yeaftPendingConversationPromotions?.[t]||null;return!n?.sourceConversationId||!n.targetConversationId||s&&n.targetConversationId!==s?null:n}function Cr(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function In(e,t,s=null){let n=mt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Cn(e,t,s){let n=mt(e,t);return!n||!s||n.targetConversationId===s?null:(ht(e,n.targetConversationId,s,{removeSource:!0}),Sn(e,t,n.targetConversationId,s),Cr(e,t,n.sourceConversationId,s),n)}function ht(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;_m(e,t,s),Vs(e.processingConversations,t,s,{removeSource:n}),Vs(e.executionStatusMap,t,s,{removeSource:n}),Vs(e.refreshingSessionMap,t,s,{removeSource:n}),Vs(e._closedAt,t,s,{removeSource:n}),Vs(e._autoRefreshed,t,s,{removeSource:n}),Vs(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=!!e._processingWatchdogs?.[t];if(n&&i&&Ae(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(i||r)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let a=Ir(e.sessionHealth,s),l=e.sessionHealth?.[s],c=Ir(e._autoRefreshed,s),d=e._autoRefreshed?.[s];kn(e,s),a&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=l),c&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=d)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var Co=F(()=>{Ds();Sr();Nt()});function Ar(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 Ao=F(()=>{});function xo(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Dm(){return Date.now()}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function $m(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Vm(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"?$m(n):n);return t}function An(){return Lm()}function Xe(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Dm(),monotonicMs:xo(),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:Vm(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),Fm(e))}function Fm(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Om(e),250))}function Om(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 xr(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=xo();requestAnimationFrame(()=>{requestAnimationFrame(()=>{Xe(e,{...t,phase:t.phase||"render.next_paint",durationMs:xo()-s})})})}var To=F(()=>{});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}var Tr=F(()=>{});function Mo(e){return typeof e=="string"&&e?e:null}function Fs(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function xn(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 vc(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Pe(t,s),a=Fs(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},Tn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function Po(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Pe(n,s),i=Fs(e,r),o=Mo(t.requestId);if(!i)return o===null;let a=Mo(i.requestId);return o?o===a:a===null}function yc(e,t={},s={},n="chunk"){if(!Po(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=Fs(e,o)||{},l=Mo(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},Tn(e),d}function bc(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=Fs(e,i);return!o||o.requestId!==n||!o.loading?!1:(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[i]:{...o,loading:!1,error:r,requestId:null,completedAt:Date.now()}},Tn(e),!0)}function Tn(e){let{sessionKey:t}=xn(e),s=t?Fs(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading,e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Ro(e){let{sessionKey:t}=xn(e);return t?Fs(e,t):null}var hc,_o=F(()=>{Tr();hc=15e3});function Ic(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function wc(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 Hm(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 qm(e){return Array.isArray(e?.toolCalls)?e.toolCalls.filter(t=>t?.name!=="TodoWrite").length:Number(e?.toolSummaryCount||0)||0}function Nm(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 Bm(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Nm(t)}function Mr(e){return e&&(e.messageId||e.id)?e.messageId||e.id:null}function Wm(e){e.sort((t,s)=>(t.timestamp||0)-(s.timestamp||0))}function Um(e,t){if(!e||!t||e.type!=="assistant"||t.type!=="assistant"||(e.sessionId??null)!==(t.sessionId??null))return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i||!(e.isStreaming||e.isHistory!==!0)||t._hasPersistedTurnId!==!0)return!1;let a=e.turnId||"",l=t.turnId||"";if(!a||!l||a!==l)return!1;let c=typeof e.content=="string"?e.content:"",d=typeof t.content=="string"?t.content:"";return!!c&&!!d&&(d.startsWith(c)||c.startsWith(d))}function Eo(e,t){let s=new Map,n=new Map;e.forEach((i,o)=>{let a=Mr(i);a&&s.set(a,o),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,o)});let r=0;for(let i of t){let o=Mr(i),a=o&&s.has(o)?s.get(o):null;if(a===null&&i?.type==="user"&&i.clientMessageId&&n.has(i.clientMessageId)&&(a=n.get(i.clientMessageId)),a===null&&i?.type==="assistant"&&(a=e.findIndex(l=>Um(l,i))),a!==null&&a>=0){let l=Mr(e[a]);e[a]={...e[a],...i},o&&s.set(o,a),l&&l!==o&&s.get(l)===a&&s.delete(l),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,a)}else o&&s.set(o,e.length),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,e.length),e.push(i),r+=1}return Wm(e),r}function Pr(e){return e?e.sessionId??e.groupId??null:null}function jm(e){return!e||e.type!=="user"||!e.clientMessageId?!1:Mr(e)===e.clientMessageId}function zm(e,t,s){let n=e.some(o=>o&&(s==null||Pr(o)===s));if(t.length===0&&n)return{insertedRows:0,preservedEmpty:!0};let r=t.reduce((o,a)=>Math.max(o,a?.timestamp||0),0),i=e.filter(o=>o?s!=null&&Pr(o)!==s||o.isStreaming||o.type==="tool-use"&&o.toolName==="AskUserQuestion"&&(o.askAnswered||o.askPending||o.askExpired)||jm(o)?!0:r>0&&(o.timestamp||0)>r:!1);return e.splice(0,e.length,...i),Eo(e,t),{insertedRows:t.length,preservedEmpty:!1}}function Km(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 Ym(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function Gm(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=xn(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if($s(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&ht(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=mt(e,r);a&&a.targetConversationId!==n&&Cn(e,r,n);let l=mt(e,r,n);if(l&&(ht(e,l.sourceConversationId,n,{removeSource:!0}),In(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=Ym(e,r);c&&(ht(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Bt(e,t){let s=e.messagesMap[t]||[];for(let n of s)n.type==="tool-use"&&!n.hasResult&&(n.hasResult=!0,n.toolName==="AskUserQuestion"&&!n.askAnswered&&!n.selectedAnswers&&(n.isHistory=!0,n.askRequestId=null))}function Cc(e,t){gt(e);let s=e.agents.find(r=>r.id===t.agentId);e.conversations=e.conversations.filter(r=>r.id!==t.conversationId);let n=t.provider||"claude-code";if(e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:null,createdAt:Date.now(),processing:!1,connecting:n!=="claude-code",type:"chat",provider:n,capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let r=e._pendingPaneId;if(e._pendingPaneId=null,r){let i=e.panels.find(o=>o.id===r);i&&(i.conversationId=t.conversationId)}else{let i=e.panels.find(o=>!o.conversationId);i&&(i.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Ac(e,t){gt(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId)),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=Ic(t.dbMessages.map(o=>e.formatDbMessageForHistoryHydration(o)).flat().filter(Boolean)),r=mo(n),i=e.messagesMap[t.conversationId]||[];for(let o of r)i.push(o)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:ss(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function Do(e,t){e.conversations=e.conversations.filter(n=>n.id!==t.conversationId),delete e.messagesMap[t.conversationId],delete e.chatSessionState[t.conversationId],delete e.conversationTitles[t.conversationId],delete e.customConversationTitles[t.conversationId],delete e.processingConversations[t.conversationId],e._closedAt&&delete e._closedAt[t.conversationId],Ae(e,t.conversationId),delete e.executionStatusMap[t.conversationId],delete e.subagents[t.conversationId],window.dispatchEvent(new CustomEvent("conversation-deleted",{detail:{conversationId:t.conversationId}}));let s=e.activeConversations.indexOf(t.conversationId);s>=0&&(e.activeConversations.splice(s,1),e.activeConversations.length===0&&e.addMessage({type:"system",content:Ee("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function xc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(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 Tc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(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 Mc(e,t){if(t.conversationId){if(t.isProcessing&&!ns(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ae(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Pc(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(e,s)}}function Rc(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=mo(Ic((t.messages||[]).map(a=>e.formatDbMessageForHistoryHydration(a)).flat().filter(Boolean)));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&Ar(d,l)):c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&d.type==="assistant"&&d.content===l.content),c){c.dbMessageId=l.dbMessageId,c.id=l.id,l.timestamp&&(c.timestamp=l.timestamp),l.clientMessageId&&!c.clientMessageId&&(c.clientMessageId=l.clientMessageId);continue}}n.push(l)}}}r||(e.hasMoreMessages=t.hasMore??!1),gt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:ss(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 _c(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let{formatted:i}=Ec(t.messages,s,"window",e.messagesMap[r]);return Eo(e.messagesMap[r],i),r}function kc(e){return e?.toolId?[Pr(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Sc(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function Qm(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Pr(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Ec(e,t,s,n){let r=new Set((n||[]).map(l=>l&&(l.messageId||l.id)).filter(Boolean)),i=new Set,o=[],a=0;for(let l of e){if(!l||l._reflection||l.internal||l.systemOnly||l.systemOnlyMessage||Km(l.content))continue;let c=l.id||l.messageId||null,d=l.clientMessageId||null;if(!(c&&i.has(c))&&!(c&&s!=="recent"&&r.has(c))){if(c&&i.add(c),l.role==="user"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null;o.push({...c?{id:c,messageId:c}:{},type:"user",content:l.content,timestamp:wc(l),sessionId:f,turnId:l.turnId||u,...d?{clientMessageId:d}:{},...Array.isArray(l.attachments)&&l.attachments.length>0?{attachments:l.attachments}:{},...l.quote?{quote:l.quote}:{},isStreaming:!1})}else if(l.role==="assistant"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null,p=Bm(l,f),g=wc(l),b=!!l.turnId,h=l.turnId||u,A=typeof l.content=="string"?l.content:l.content||"",w=Array.isArray(l.todos)?l.todos:Hm(l.toolCalls);(typeof A!="string"||A.trim())&&o.push({...c?{id:c,messageId:c}:{},type:"assistant",content:A,timestamp:g,sessionId:f,turnId:h,_hasPersistedTurnId:b,...p?{vpId:p,speakerVpId:p}:{},...l.responseKind==="progress"||l.responseKind==="result"?{responseKind:l.responseKind}:{},...l.incomplete===!0?{incomplete:!0}:{},...typeof l.stopReason=="string"&&l.stopReason?{stopReason:l.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&o.push({...c?{id:`${c}:todos`,messageId:`${c}:todos`}:{},type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let y of Array.isArray(l.images)?l.images:[])y?.assetId&&o.push({id:`${c||u||h}:image:${y.assetId}`,messageId:`${c||u||h}:image:${y.assetId}`,type:"chat-image",...y,timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0});for(let y of Array.isArray(l.askUserResults)?l.askUserResults:[]){if(!y?.toolCallId||y.status!=="answered"&&y.status!=="expired")continue;let m=[{question:typeof y.question=="string"?y.question:"",options:(Array.isArray(y.options)?y.options:[]).filter(L=>typeof L=="string").map(L=>({label:L,description:""})),multiSelect:!1}],v={toolCallId:y.toolCallId,sessionId:f,vpId:p||"",turnId:h||"",threadId:l.threadId||"main"},E=Qm(n,v);if(E){Sc(E,y,m);continue}let V=Sc({id:`${c||u||h}:ask:${y.toolCallId}`,messageId:`${c||u||h}:ask:${y.toolCallId}`,type:"tool-use",timestamp:g,sessionId:f,turnId:h,threadId:v.threadId,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1},y,m),U=kc(V);(!U||!o.some(L=>kc(L)===U))&&o.push(V)}let S=qm(l);S>0&&o.push({...c?{id:`${c}:tool-summary`,messageId:`${c}:tool-summary`,persistedMessageId:c}:{},type:"tool-summary",count:S,omittedCount:S,source:"history",timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0})}}}return{formatted:o,acceptedHistoryMessages:a}}function Dc(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if($s(e,n,t.conversationId)){let v=e.yeaftConversationIdsByAgent?.[n]||null;if(!v||v===t.conversationId)return;ht(e,t.conversationId,v,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:v}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[];t.perfTraceId&&Xe(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let o=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),a=o&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[o]:null,l=t.conversationId||a||e.yeaftConversationId;if(!l){e.yeaftLoadingMoreHistory=!1;return}Gm(e,t,s,l),e.messagesMap[l]||(e.messagesMap[l]=[]);let{formatted:c,acceptedHistoryMessages:d}=Ec(i,s,r,e.messagesMap[l]),u=0,f=!1;if(r==="recent"){let v=zm(e.messagesMap[l],c,s??null);u=v.insertedRows,f=v.preservedEmpty}else if(c.length>0)if(r==="older"){if(e.messagesMap[l].splice(0,0,...c),u=c.length,typeof e.expandYeaftMessageWindow=="function"){let v=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(v,t.turns||10)}}else u=Eo(e.messagesMap[l],c);let p=Pe(t.agentId||null,s),g=e.yeaftSessionHistoryState?.[p]||{},b=typeof t.latestSeq=="number"?t.latestSeq:g.latestSeq??null,h=r==="delta"?{...g,loaded:!0,loading:!1,latestSeq:b,syncingAfterSeq:null,count:(g.count||0)+u}:{...f?g:{},loaded:!0,loading:!1,hasMore:f?!!g.hasMore:!!t.hasMore,oldestSeq:f?Number.isFinite(g.oldestSeq)?g.oldestSeq:e.yeaftOldestLoadedSeq:typeof t.oldestSeq=="number"?t.oldestSeq:e.yeaftOldestLoadedSeq,count:r==="older"?(g.count||0)+u:f?g.count||0:d,latestSeq:f&&!Number.isFinite(t.latestSeq)?g.latestSeq??null:b,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,h,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[p]:h});let A=xn(e),w=A.sessionId===(s||null),S=!t.agentId||!A.agentId||t.agentId===A.agentId,y=w&&S,m=Pe(null,A.sessionId);if(t.perfTraceId&&(Xe(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:c.length,insertedRows:u,acceptedHistoryMessages:d,preservedEmptyRecent:f}}),xr(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:u}})),y)e.yeaftHasMoreHistory=h.hasMore,typeof t.oldestSeq=="number"&&(e.yeaftOldestLoadedSeq=t.oldestSeq),e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let v=e.yeaftSessionHistoryState?.[A.sessionKey]||e.yeaftSessionHistoryState?.[m]||null;e.yeaftLoadingMoreHistory=!!v?.loading}}var Rr=F(()=>{Nt();Co();Sr();ts();Ao();Ds();ho();xt();To();_o();Tr()});function Lc(e,t){if(e.promoteYeaftHistoryOutlineRow?.(t))return;let s=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;s&&e.invalidateYeaftHistoryOutline?.(s)}function Xm(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 Lo(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function $c(e,t,s){if(!t)return;let n=Lo(e,t);if(n.lastActivity=Date.now(),kr(e,t),s.type==="system"){if(s.subtype==="init"){let r=e.conversations.find(i=>i.id===t);r&&r.connecting&&(r.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let r=s.message?.content;if(!r)return;let i=e.messagesMap[t]||[];for(let o of i)o.type==="tool-use"&&!o.hasResult&&(o.hasResult=!0);for(let o of n.toolHistory)o.status==="running"&&(o.status="done");if(n.currentTool=null,typeof r=="string"){e.appendToAssistantMessageForConversation(t,r,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(r))return;if(r.length===0){e.finishStreamingForConversation(t);return}for(let o of r)o.type==="text"?e.appendToAssistantMessageForConversation(t,o.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="image_asset"&&o.image?e.addMessageToConversation(t,{type:"chat-image",...o.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_summary"?e.addMessageToConversation(t,{type:"tool-summary",count:Number(o.count||o.omittedCount||0)||0,omittedCount:Number(o.omittedCount||o.count||0)||0,source:o.source||"history",isHistory:o.source!=="live",sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),n.currentTool={name:o.name,input:o.input,startTime:Date.now()},n.toolHistory.unshift({name:o.name,input:o.input,timestamp:Date.now(),status:"running"}),n.toolHistory.length>20&&n.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:o.id||o.tool_use_id||null,toolName:o.name,toolInput:o.input,startTime:Date.now(),sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let r=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,i=s.message?.content,o=Xm(i);if(typeof o=="string"&&(o.includes("<local-command-caveat>")||o.includes("<command-name>")))return;if(typeof o=="string"&&o.includes("<local-command-stdout>")){let l=o.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(l){e.appendToAssistantMessageForConversation(t,l[1].trim()),e.finishStreamingForConversation(t);return}}let a=[];if(s.tool_use_result)a=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let l=s.message.content;a=(Array.isArray(l)?l:[]).filter(d=>d.type==="tool_result")}if(a.length>0){let l=e.messagesMap[t]||[];for(let c of a){if(n.toolHistory.length>0){let p=n.toolHistory.findIndex(g=>g.status==="running");p>=0&&(n.toolHistory[p].status="done")}let d=c.tool_use_id||c.toolUseId||c.tool_call_id||c.toolCallId||null,u=c.content||c,f=!1;if(d){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&l[p].toolId===d){l[p].hasResult=!0,l[p].toolResult=c.is_update&&l[p].toolResult?`${l[p].toolResult}
|
|
1
|
+
var F=(e,t,s)=>()=>{if(s)throw s[0];try{return e&&(t=e(e=0)),t}catch(n){throw s=[n],n}};var cm=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(s){throw t=0,s}};function yl(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 bl(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 wl(e){return e&&typeof e=="object"&&typeof e.n=="string"&&typeof e.c=="string"}function at(e){return nacl.util.decodeBase64(e)}var gr=F(()=>{});function Ct(){return globalThis.localStorage||null}function Sl(){let e=hr();for(let t of ro)try{t(e)}catch{}}function dm(){try{Ct()?.removeItem(pn),Ct()?.removeItem(fn)}catch{}}function um(e){return String(e||"").trim()||null}function kl(e,t){if(!gn(t))return{};try{let s=JSON.parse(Ct()?.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)?(Ct()?.removeItem(e),{}):s.records}catch{try{Ct()?.removeItem(e)}catch{}return{}}}function Il(e,t,s){if(!gn(s))return!1;try{return Ct()?.setItem(e,JSON.stringify({ownerId:s.ownerId,records:t||{}})),!0}catch{return!1}}function lt(e){let t=um(e);if(!t)return io(),null;if(ts!==t){ts=t,mr+=1;for(let s of[pn,fn])try{let n=JSON.parse(Ct()?.getItem(s)||"null");(!n||n.ownerId!==t)&&Ct()?.removeItem(s)}catch{try{Ct()?.removeItem(s)}catch{}}Sl()}return hr()}function io(){ts=null,mr+=1,dm(),Sl()}function hr(){return ts?{ownerId:ts,epoch:mr}:null}function gn(e){return!!e&&!!ts&&e.ownerId===ts&&e.epoch===mr}function Cl(e){return{drafts:kl(pn,e),outbox:kl(fn,e)}}function oo(e,t){return Il(pn,e,t)}function mn(e,t){return Il(fn,e,t)}function Al(e){return typeof e!="function"?()=>{}:(ro.add(e),()=>ro.delete(e))}var pn,fn,ts,mr,ro,Ky,ao=F(()=>{pn="yeaft-work-center-composer-drafts-v1",fn="yeaft-work-center-message-outbox-v1",ts=null,mr=0,ro=new Set;Ky=Object.freeze({drafts:pn,outbox:fn})});var pm,fm,_e,ct=F(()=>{gr();ao();({defineStore:pm}=Pinia),fm=1800*1e3,_e=pm("auth",{state:()=>({skipAuth:!1,emailVerification:!1,passwordResetEnabled:!1,totpEnabled:!1,registrationEnabled:!1,aadEnabled:!1,aadClientId:null,aadTenantId:null,ssoProviders:{github:!1,google:!1,wechat:!1,alipay:!1},linkedIdentities:[],hasPassword:!1,identitiesLoading:!1,identitiesError:null,initialized:!1,authGeneration:0,isAuthenticated:!1,token:null,sessionKey:null,userId:null,role:null,loginStep:"credentials",tempToken:null,emailHint:null,setupToken:null,totpSecret:null,qrCode:null,error:null,loading:!1,qrPanel:null,_qrPollTimer:null,_sessionRefreshTimer:null,_sessionRefreshVisibilityHandler:null}),actions:{async initialize(){if(this.initialized)return this.isAuthenticated;try{if(await this.checkAuthMode(),this.skipAuth&&this.isAuthenticated)return!0;let e=!1;return typeof window<"u"&&typeof this.consumeSsoRedirect=="function"&&(e=this.consumeSsoRedirect()),!this.isAuthenticated&&!e&&await this.restoreSession(),this.isAuthenticated}finally{this.initialized=!0}},async checkAuthMode(){try{let t=await(await fetch("/api/auth/mode")).json();this.skipAuth=t.skipAuth,this.emailVerification=t.emailVerification,this.passwordResetEnabled=!!t.passwordResetEnabled,this.totpEnabled=t.totpEnabled,this.registrationEnabled=t.registrationEnabled||!1,this.aadEnabled=t.aadEnabled||!1,this.aadClientId=t.aadClientId||null,this.aadTenantId=t.aadTenantId||null,this.ssoProviders=Object.assign({github:!1,google:!1,wechat:!1,alipay:!1},t.ssoProviders||{}),this.skipAuth&&(this.userId="skip-auth",lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated")}catch{}},async login(e,t){this.loading=!0,this.error=null;try{let n=await(await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t})})).json();return n.success?n.needTotpSetup?(this.setupToken=n.setupToken,this.totpSecret=n.totpSecret,this.qrCode=n.qrCode,this.loginStep="totp-setup",!0):n.needTotpCode?(this.tempToken=n.tempToken,this.loginStep="totp",!0):n.needEmailCode?(this.tempToken=n.tempToken,this.emailHint=n.emailHint,this.loginStep="verification",!0):(this.token=n.token,this.sessionKey=n.sessionKey?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),!0):(this.error=n.error||"Login failed",!1)}catch(s){return this.error=s.message||"Network error",!1}finally{this.loading=!1}},async loginWithMicrosoft(){if(!this.aadEnabled||!this.aadClientId||!this.aadTenantId)return this.error="Microsoft login is not configured",!1;if(typeof msal>"u"||!msal.PublicClientApplication)return this.error="Microsoft authentication library not loaded",!1;this.loading=!0,this.error=null;try{let e={auth:{clientId:this.aadClientId,authority:`https://login.microsoftonline.com/${this.aadTenantId}`,redirectUri:window.location.origin+"/auth/callback"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1}},t=new msal.PublicClientApplication(e);await t.initialize();let s=await t.loginPopup({scopes:["openid","profile","email"]});if(!s||!s.idToken)return this.error="Microsoft login failed: no token received",!1;let r=await(await fetch("/api/auth/aad",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:s.idToken})})).json();return r.success?(this.token=r.token,this.sessionKey=r.sessionKey?at(r.sessionKey):null,this.role=r.role||"pro",this.userId=r.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",r.token),this.startSessionRefresh(),!0):(this.error=r.error||"Microsoft login failed",!1)}catch(e){return e.errorCode==="user_cancelled"||e.name==="BrowserAuthError"?(this.error=null,!1):(this.error=e.message||"Microsoft login failed",!1)}finally{this.loading=!1}},async verifyTotpCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,totpCode:e})})).json();return s.success?s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"TOTP verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async completeTotpSetup(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/setup-totp",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({setupToken:this.setupToken,totpCode:e})})).json();return s.success?(this.setupToken=null,this.totpSecret=null,this.qrCode=null,s.needEmailCode?(this.tempToken=s.tempToken,this.emailHint=s.emailHint,this.loginStep="verification",!0):(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0)):(this.error=s.error||"TOTP setup failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async verifyCode(e){this.loading=!0,this.error=null;try{let s=await(await fetch("/api/auth/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tempToken:this.tempToken,code:e})})).json();return s.success?(this.token=s.token,this.sessionKey=s.sessionKey?at(s.sessionKey):null,this.role=s.role||"pro",this.userId=s.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.tempToken=null,this.emailHint=null,localStorage.setItem("authToken",s.token),this.startSessionRefresh(),!0):(this.error=s.error||"Verification failed",!1)}catch(t){return this.error=t.message||"Network error",!1}finally{this.loading=!1}},async register(e,t,s,n){this.loading=!0,this.error=null;try{let i=await(await fetch("/api/auth/register",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:e,password:t,email:s||void 0,invitationCode:n})})).json();return i.success?!0:(this.error=i.error||"Registration failed",!1)}catch(r){return this.error=r.message||"Network error",!1}finally{this.loading=!1}},showRegister(){this.loginStep="register",this.error=null},loginWithSso(e){window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start`},async loginWithAlipayMobile({intent:e="login"}={}){if(!await this.startSsoQr("alipay",{intent:e}))return!1;let s=this.qrPanel?.authorizeUrl;if(!s)return!1;let n=`alipays://platformapi/startapp?appId=20000067&url=${encodeURIComponent(s)}`;return this.qrPanel={...this.qrPanel,mobileDeepLink:!0},window.location.href=n,!0},async startSsoQr(e,{intent:t="login"}={}){this.cancelSsoQr(),this.error=null;try{let s=new URLSearchParams;if(t==="bind"){if(!this.isAuthenticated)return this.error="You must be logged in to bind an identity",!1;s.set("intent","bind")}let n=s.toString(),r=`/api/auth/sso/${encodeURIComponent(e)}/start-qr${n?"?"+n:""}`,i=await fetch(r),o=await i.json();return!i.ok||!o.success?(this.error=o.error||"Failed to start QR login",!1):(this.qrPanel={provider:e,intent:t,authorizeUrl:o.authorizeUrl,state:o.state,status:"pending",error:null},this._startQrPoll(),!0)}catch(s){return this.error=s.message||"Network error",!1}},_startQrPoll(){this._stopQrPollTimer();let e=async()=>{if(!this.qrPanel)return;let t=this.qrPanel.state;try{let n=await(await fetch(`/api/auth/sso/poll/${encodeURIComponent(t)}`)).json();if(!this.qrPanel||this.qrPanel.state!==t||n.status==="pending")return;if(n.status==="login"){this.token=n.token,this.sessionKey=n.sessionKey?at(n.sessionKey):null,this.role=n.role||"pro",this.userId=n.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n.token),this.startSessionRefresh(),this.cancelSsoQr();return}if(n.status==="bind"){this.qrPanel={...this.qrPanel,status:"bound"},this._stopQrPollTimer();return}this.qrPanel={...this.qrPanel,status:"error",error:n.error||"SSO failed"},this._stopQrPollTimer()}catch{}};this._qrPollTick=e,this._qrPollTimer=setInterval(e,2e3),typeof document<"u"&&!this._qrVisHandler&&(this._qrVisHandler=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||!this.qrPanel||!this._qrPollTick||(this._qrPollTick(),this._qrPollTimer&&clearInterval(this._qrPollTimer),this._qrPollTimer=setInterval(this._qrPollTick,2e3))},document.addEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.addEventListener("pageshow",this._qrVisHandler))},_stopQrPollTimer(){this._qrPollTimer&&(clearInterval(this._qrPollTimer),this._qrPollTimer=null),this._qrVisHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._qrVisHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._qrVisHandler),this._qrVisHandler=null),this._qrPollTick=null},cancelSsoQr(){this._stopQrPollTimer(),this.qrPanel=null},bindSso(e){if(!this.isAuthenticated){this.error="You must be logged in to bind an identity";return}let t=new URLSearchParams({intent:"bind"});window.location.href=`/api/auth/sso/${encodeURIComponent(e)}/start?${t.toString()}`},consumeSsoRedirect(){let e=window.location.hash||"",t=e.indexOf("?");if(!e.startsWith("#/sso-complete")||t<0)return!1;let s=new URLSearchParams(e.slice(t+1)),n=s.get("token"),r=s.get("sessionKey"),i=s.get("role"),o=s.get("userId");if(!n)return!1;this.token=n,this.sessionKey=r?at(r):null,this.role=i||"pro",this.userId=o||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",localStorage.setItem("authToken",n),this.startSessionRefresh();try{history.replaceState(null,"",window.location.pathname+window.location.search)}catch{}return!0},async loadIdentities(){if(this.isAuthenticated){this.identitiesLoading=!0,this.identitiesError=null;try{let e=await fetch("/api/auth/identities"),t=await e.json();if(!e.ok||!t.success){this.identitiesError=t.error||"Failed to load identities";return}this.linkedIdentities=t.identities||[],this.hasPassword=!!t.hasPassword}catch(e){this.identitiesError=e.message||"Network error"}finally{this.identitiesLoading=!1}}},async unbindIdentity(e){if(!this.isAuthenticated)return!1;this.identitiesError=null;try{let t=await fetch(`/api/auth/identities/${encodeURIComponent(e)}`,{method:"DELETE"}),s=await t.json();return!t.ok||!s.success?(this.identitiesError=s.error||"Failed to unbind",!1):(this.linkedIdentities=this.linkedIdentities.filter(n=>n.provider!==e),!0)}catch(t){return this.identitiesError=t.message||"Network error",!1}},async refreshSession(){let e=this.token,t=this.authGeneration,s=this.isAuthenticated;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s)||!n.ok)return!1;let r=await n.json().catch(()=>({}));if(t!==this.authGeneration||this.token!==e)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=localStorage.getItem("authToken");return i&&this.token===e&&(!o||o===e)&&(this.token=i,localStorage.setItem("authToken",i)),r?.role&&(this.role=r.role),this.userId=r?.userId||null,lt(this.userId),!0}catch{return!1}},startSessionRefresh(){if(this.stopSessionRefresh(),!this.isAuthenticated||this.skipAuth)return;let e=()=>{typeof document<"u"&&document.visibilityState&&document.visibilityState!=="visible"||this.refreshSession()};this._sessionRefreshTimer=setInterval(e,fm),this._sessionRefreshVisibilityHandler=e,typeof document<"u"&&document.addEventListener("visibilitychange",e),typeof window<"u"&&window.addEventListener("pageshow",e)},stopSessionRefresh(){this._sessionRefreshTimer&&(clearInterval(this._sessionRefreshTimer),this._sessionRefreshTimer=null),this._sessionRefreshVisibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this._sessionRefreshVisibilityHandler),typeof window<"u"&&window.removeEventListener("pageshow",this._sessionRefreshVisibilityHandler),this._sessionRefreshVisibilityHandler=null)},async logout(){try{let e={"Content-Type":"application/json"};this.token&&(e.Authorization=`Bearer ${this.token}`),await fetch("/api/auth/logout",{method:"POST",headers:e})}catch{}this.clearStoredSession()},clearStoredSession(e=null){this.reset(),localStorage.removeItem("authToken"),e&&(this.error=e)},getActiveToken(){if(this.token)return this.token;let e=localStorage.getItem("authToken");return e&&(this.token=e),this.token},handleAuthResponse(e,t=null,s=this.authGeneration,n=this.isAuthenticated,r=void 0){if(!e||e.status!==401||!n||s!==this.authGeneration)return!1;let i=this.token||localStorage.getItem("authToken")||null;return t!==i?!1:(this.handleAuthFailure(r,t,s),!0)},handleAuthFailure(e="Session expired. Please log in again.",t=null,s=this.authGeneration){if(s!==this.authGeneration)return!1;let n=this.token||localStorage.getItem("authToken")||null;return t!==n||this.clearStoredSession(e),!1},async restoreSession(){let e=localStorage.getItem("authToken"),t=this.authGeneration,s=this.isAuthenticated||!!e;try{let n=await fetch("/api/user/profile",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(this.handleAuthResponse(n,e,t,s))return!1;if(!n.ok)return this.error="Failed to restore session",!1;let r=await n.json();if(t!==this.authGeneration)return this.isAuthenticated;let i=n.headers?.get?.("X-New-Token"),o=this.getActiveToken();if(o!==e)return this.isAuthenticated;let a=i&&(!o||o===e)?i:o||e;return this.token=a,a&&a!==e&&localStorage.setItem("authToken",a),this.role=r?.role||"pro",this.userId=r?.userId||null,lt(this.userId),this.authGeneration+=1,this.isAuthenticated=!0,this.loginStep="authenticated",this.startSessionRefresh(),!0}catch(n){return this.error=n.message||"Failed to restore session",!1}},setSessionKey(e){e&&(this.sessionKey=at(e))},backToCredentials(){this.loginStep="credentials",this.tempToken=null,this.emailHint=null,this.setupToken=null,this.totpSecret=null,this.qrCode=null,this.error=null},async requestPasswordReset(e){this.error=null;try{let s=await(await fetch("/api/auth/password-reset/request",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e})})).json();return s.success?s.resetToken||null:(this.error=s.error||"Failed to request password reset",null)}catch(t){return this.error=t.message||"Network error",null}},async verifyPasswordReset(e,t,s){this.error=null;try{let r=await(await fetch("/api/auth/password-reset/verify",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resetToken:e,code:t,newPassword:s})})).json();return r.success?!0:(this.error=r.error||"Failed to reset password",!1)}catch(n){return this.error=n.message||"Network error",!1}},async deleteAccount({currentPassword:e,confirm:t}={}){if(!this.isAuthenticated)return{success:!1,error:"Not authenticated"};try{let s=await fetch("/api/user/me",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:e,confirm:t})}),n=await s.json();return!s.ok||!n.success?{success:!1,error:n.error||"Failed to delete account"}:(this.clearStoredSession(),{success:!0})}catch(s){return{success:!1,error:s.message||"Network error"}}},reset(){io(),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=At?.value||"zh-CN",r=(Ps[s]||Ps["zh-CN"]||{})[e];if(r===void 0&&s!=="zh-CN"&&(r=(Ps["zh-CN"]||{})[e]),r===void 0)return e;if(t)for(let[i,o]of Object.entries(t))r=r.replace(new RegExp(`\\{${i}\\}`,"g"),o);return r}function gm(){return At?.value||"zh-CN"}function hn(e){Ps[e]&&(At&&(At.value=e),localStorage.setItem("locale",e),document.documentElement.setAttribute("lang",e))}function mm(){let e=localStorage.getItem("locale");return e&&Ps[e]?e:(navigator.language||navigator.userLanguage||"").startsWith("en")?"en":"zh-CN"}function xl(e,t){return Ps=t,At=Vue.ref(mm()),document.documentElement.setAttribute("lang",At.value),e.config.globalProperties.$t=Ee,e.config.globalProperties.$locale=At,e.provide("t",Ee),e.provide("locale",At),{t:Ee,setLocale:hn,getLocale:gm,locale:At}}var At,Ps,xt=F(()=>{At=null,Ps={}});function vr(e){if(e==null||e==="")return"claude-code";if(hm.has(e))return e;throw new Error(`Unknown Chat runtime provider: ${e}`)}function Rs(e){if(typeof e!="string"||!e)throw new Error("Chat catalog key requires conversationId");return`chat:${e}`}function yr(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 lo(e,t){let s=e.sessionCatalog.map(n=>({...n}));return e.sessionCatalogMutationRequests[t]={previousCatalog:s},s}function Tl(e,t){let s=t?.requestId?e.sessionCatalogMutationRequests[t.requestId]:null;return s?(delete e.sessionCatalogMutationRequests[t.requestId],t.ok!==!0&&(e.sessionCatalog=s.previousCatalog),!0):!1}function Ml(e,t,s="recent",n=null){let r=Rs(t),i=e.chatHistoryRequests[r]||{},o=Number(i.generation||0)+1,a=`chat_history_${o}_${crypto.randomUUID()}`;return e.chatHistoryRequests[r]={requestId:a,catalogKey:r,generation:o,mode:s,cursor:n,connectionGeneration:Number(e.chatHistoryConnectionGeneration||0),loading:!0,cancelled:!1,error:null},a}function Pl(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 hm,co=F(()=>{hm=new Set(["claude-code","copilot"])});function _s(e,t,s=""){vn&&(clearTimeout(vn),vn=null),e.sessionLoading=t,e.sessionLoadingText=s,t&&(vn=setTimeout(()=>{e.sessionLoading&&(e.sessionLoading=!1,e.sessionLoadingText=""),vn=null},vm))}function gt(e){_s(e,!1)}function Rl(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:vr(t.provider),catalogKey:t.catalogKey||null},e.recoveryDismissed=!1)}}function _l(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:vr(r)}),e.pendingRecovery=null,e.recoveryDismissed=!1},500)}function El(e){e.recoveryDismissed=!0,e.pendingRecovery=null}function Dl(e,t){let s=e.conversations.find(n=>n.id===t);s&&(e.activeConversations=[t],e.currentWorkDir=s.workDir,e.messagesMap[t]?.length>0||(s.claudeSessionId?(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory")),e.sendWsMessage({type:"resume_conversation",agentId:s.agentId||e.currentAgent,claudeSessionId:s.claudeSessionId,workDir:s.workDir,conversationId:t})):(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5}))),e.sendWsMessage({type:"select_conversation",conversationId:t}))}function Ll(e){if(e.panels.length>0)return;let t=localStorage.getItem("panels");if(!t)return;let s;try{s=JSON.parse(t)}catch{localStorage.removeItem("panels");return}if(!Array.isArray(s)||s.length<2){localStorage.removeItem("panels");return}let n=new Set(e.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({id:i.id,conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null,activeRightPanel:i.activeRightPanel||null}));if(r.length<2){localStorage.removeItem("panels");return}e.panels=r,e.activePanelId=r[0]?.id||null;for(let i of r)i.conversationId&&(e.activeConversations.includes(i.conversationId)||e.activeConversations.push(i.conversationId),e.messagesMap[i.conversationId]||(e.messagesMap[i.conversationId]=[]),e.messagesMap[i.conversationId].length||e.requestChatHistory?.(i.conversationId,{mode:"recent",turns:5}))}function Es(e){if(e.currentAgent){if(localStorage.setItem("lastUsedAgent",e.currentAgent),localStorage.setItem("lastViewedConversation",e.currentConversation||""),e.lastViewedConversation=e.currentConversation,e.currentConversation){let t=e.conversations.find(s=>s.id===e.currentConversation);if(t?.claudeSessionId&&t?.workDir){let s=vr(t.provider),n={sessionId:t.claudeSessionId,workDir:t.workDir,agentId:t.agentId||e.currentAgent,provider:s,catalogKey:Rs(t.id),version:2};localStorage.setItem("lastUsedSession",JSON.stringify(n)),localStorage.setItem("lastViewedSessionRef",JSON.stringify(n)),e.lastUsedSession=n}}e.lastUsedAgent=e.currentAgent,e.panels.length>0?localStorage.setItem("panels",JSON.stringify(e.panels)):localStorage.removeItem("panels")}}function $l(e){return e.lastUsedSession}function Vl(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 Fl(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 Ol(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 Hl(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 ql(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 Nl(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 Bl(e,t=20){if(_e().isAuthenticated){e.globalSessionsLoading=!0;try{let n=await fetch(`/api/sessions?limit=${t}`);if(n.ok){let r=await n.json();e.globalSessions=r.sessions||[]}}catch{}finally{e.globalSessionsLoading=!1}}}async function Wl(e,t){if(!_e().isAuthenticated)return!1;try{if((await fetch(`/api/sessions/${t}`,{method:"DELETE"})).ok)return e.globalSessions=e.globalSessions.filter(r=>r.id!==t),!0}catch{}return!1}function uo(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 Ul(e,t){let s=uo(e,t);return s&&s.online}var vm,vn,ss=F(()=>{ct();xt();co();vm=3e4,vn=null});function jl(e){return e?.code===1008&&String(e.reason||"").toLowerCase().includes("authentication")}function zl(e){let t=yn;yn=[];for(let{resolve:s,reject:n,timer:r}of t)clearTimeout(r),e?s():n(new Error("WebSocket reconnect failed"))}function Kl(e,t){if(!e.ws||e.ws.readyState!==WebSocket.OPEN)return!1;if(e.currentView==="yeaft"&&bm.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=yl(t,e.sessionKey);e.ws.send(JSON.stringify(s))}else e.ws.send(JSON.stringify(t));return!0}catch{return!1}}function bn(e,t=1e4){return e.ws&&e.ws.readyState===WebSocket.OPEN?Promise.resolve():new Promise((s,n)=>{let r=setTimeout(()=>{yn=yn.filter(i=>i.resolve!==s),n(new Error("WebSocket reconnect timeout"))},t);yn.push({resolve:s,reject:n,timer:r}),(!e.ws||e.ws.readyState!==WebSocket.CONNECTING)&&(e.reconnectAttempts=0,e.connect())})}function Yl(e,t){try{let s=JSON.parse(t);return e.sessionKey&&wl(s)?bl(s,e.sessionKey):s}catch{return null}}function Gl(e){let t=_e(),s=location.protocol==="https:"?"wss:":"ws:";e.reconnectTimer&&(clearTimeout(e.reconnectTimer),e.reconnectTimer=null);let n=t.getActiveToken?.()||t.token||null,r=t.authGeneration;if(e.ws&&e.ws.readyState===WebSocket.CONNECTING&&e._wsAuthToken===n&&e._wsAuthGeneration===r)return;clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!1,e.pendingAgentSelection=null,e.agentSwitching=!1,e.ws&&(e.ws.onopen=null,e.ws.onmessage=null,e.ws.onclose=null,e.ws.close(),e.ws=null),e.connectionState=e.reconnectAttempts>0?"reconnecting":"connecting",e.serverEncryptionRequired=!0,e.chatHistoryRequestIdSupported=null,e.chatHistoryConnectionGeneration=Number(e.chatHistoryConnectionGeneration||0)+1;for(let[l,c]of Object.entries(e.projectMutationRequests||{}))c?.resolve?.({ok:!1,requestId:l,error:{code:"connection_changed"}});e.projectMutationRequests={},e.sessionProjects=[];for(let[l,c]of Object.entries(e.chatHistoryRequests||{}))c?.loading&&(e.chatHistoryRequests[l]={...c,loading:!1,cancelled:!0,error:"connection_changed"});let i=Object.values(e.sessionCatalogMutationRequests||{});i.length>0&&(e.sessionCatalog=i[0].previousCatalog,e.sessionCatalogMutationRequests={}),e.sessionCatalogLoaded=!1,e.sessionCatalog=[],e.activeCatalogKey=null,e._wsAuthToken=n,e._wsAuthGeneration=r;let o=`${s}//${location.host}?type=web`;n&&(o+=`&token=${encodeURIComponent(n)}`);let a=new WebSocket(o);e.ws=a,a.onopen=()=>{if(a===e.ws){e.connectionState="connected",e.reconnectAttempts=0,e.startHeartbeat();try{a.send(JSON.stringify({type:"client_hello",plaintextOk:!0}))}catch{}zl(!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){jl(l)&&t.handleAuthFailure?.(void 0,n,r);return}e.authenticated=!1,clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=null,e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionInventoryCompleteSupported=null,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateError=null,e.pendingAgentSelection=null,e.agentSwitching=!1;let c=e.connectionState==="updating";if(e.connectionState=c?"updating":"disconnected",e.stopHeartbeat(),gt(e),jl(l)){t.handleAuthFailure?.(void 0,n,r),e.reconnectAttempts=0,zl(!1);return}if(e._yeaftReconnectCatchUpPending=!0,c){e.reconnectAttempts=0,e.reconnectTimer=setTimeout(()=>{e.connect()},2e3);return}e.scheduleReconnect()},e.ws.onerror=l=>{}}function Ql(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 Xl(e){e.reconnectAttempts=0,e.connect()}function Zl(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 Jl(e){e.heartbeatTimer&&(clearInterval(e.heartbeatTimer),e.heartbeatTimer=null)}function ec(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 yn,bm,po=F(()=>{ct();gr();ss();yn=[];bm=new Set(["sync_messages","refresh_conversation","select_conversation","cancel_execution","update_conversation_settings","ask_user_answer"])});function Sm(e){return e?.type==="tool-use"}function fo(e){return e?.type==="tool-summary"}function go(e){return Sm(e)&&!km.has(e.toolName)}function nc(e,t,s,n=s){let r=t==="history"&&(n?.dbMessageId||n?.id)||null;return{...r?{id:`tool_summary_${t}_${r}`,dbMessageId:n?.dbMessageId||null}:{},type:"tool-summary",count:e,omittedCount:e,source:t,isHistory:t!=="live",timestamp:s?.timestamp||s?.startTime||n?.timestamp||n?.startTime||null,sessionId:s?.sessionId??s?.groupId??null,turnId:s?.turnId||null,vpId:s?.vpId||null,speakerVpId:s?.speakerVpId||null}}function Im(e,t){return!fo(e)||!fo(t)?!1:(e.turnId||null)===(t.turnId||null)&&(e.sessionId||null)===(t.sessionId||null)&&(e.speakerVpId||e.vpId||null)===(t.speakerVpId||t.vpId||null)&&(e.source||null)===(t.source||null)}function Cm(e,t){let s=(Number(e.count)||0)+(Number(t.count)||0);return e.count=s,e.omittedCount=s,!e.timestamp&&t.timestamp&&(e.timestamp=t.timestamp),Number(t.dbMessageId||0)>Number(e.dbMessageId||0)&&(e.dbMessageId=t.dbMessageId,t.id&&(e.id=t.id)),e}function tc(e){return[e?.sessionId||"",e?.turnId||"",e?.speakerVpId||e?.vpId||""].join("")}function sc(e,t,s,n,r=n){if(!t)return;let i=nc(t,s,n,r),o=e[e.length-1];Im(o,i)?Cm(o,i):e.push(i)}function mo(e=[]){let t=[],s=0,n=null,r=null;for(let i of e){if(go(i)&&i.isHistory){s+=1,n||(n=i),r=i;continue}sc(t,s,"history",n,r),s=0,n=null,r=null,t.push(i)}return sc(t,s,"history",n,r),t}function rc(e=[],t={}){let s=Number.isFinite(t.maxDetailed)?Math.max(1,t.maxDetailed):100;if(!Array.isArray(e)||e.length<=s)return e;let n=e.length;for(let p=e.length-1;p>=0;p-=1){let g=e[p];if(g?.type==="user"||g?.type==="system"||g?.type==="error")break;n=p}let r=e.slice(n),i=new Map;for(let p of r){if(!go(p)||p.isHistory)continue;let g=tc(p);i.set(g,(i.get(g)||0)+1)}let o=new Map;for(let[p,g]of i)g>s&&o.set(p,g-s);if(o.size===0)return e;let a=new Map,l=new Map,c=new Set,d=[],u=(p,g,b)=>{a.set(p,(a.get(p)||0)+g),!l.has(p)&&b&&l.set(p,b)},f=(p,g)=>{if(c.has(p))return;let b=a.get(p)||0;b<=0||(d.push(nc(b,"live",l.get(p)||g)),c.add(p))};for(let p of r){let g=tc(p);if(fo(p)&&p.source==="live"&&o.has(g)){u(g,Number(p.count)||0,p);continue}if(go(p)&&!p.isHistory&&o.has(g)){let b=o.get(g)||0;if(b>0){o.set(g,b-1),u(g,1,p);continue}}f(g,p),d.push(p)}for(let p of a.keys())f(p,l.get(p));return e.splice(n,e.length-n,...d),e}var km,ho=F(()=>{km=new Set(["TodoWrite","AskUserQuestion"])});function vo(e,t){return t?t===e.yeaftConversationId?!0:Object.values(e.yeaftConversationIdsByAgent||{}).includes(t):!1}function wn(e,t,s){s&&(s.type!=="assistant"&&s.type!=="tool-use"||vo(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 xm(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 br(e){let t=e?.messageId??e?.dbMessageId??e?.id;return t==null||t===""?null:String(t)}function yo(e,t){if(!e||!t)return e;let s=e.type==="user"&&typeof e.id=="string"&&e.id===e.clientMessageId;for(let[n,r]of Object.entries(t))if(r!=null){if(n==="isStreaming"){e.isStreaming&&r===!1&&(e.isStreaming=!1);continue}if(n==="id"||n==="messageId"){if(s&&t.clientMessageId===e.clientMessageId&&t.messageId&&t.messageId!==e.clientMessageId)continue;(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r);continue}if(!(n==="turnId"&&s&&e.turnId===e.clientMessageId)){if(n==="content"&&typeof r=="string"){e.content||(e.content=r);continue}if(n==="responseKind"&&(r==="progress"||r==="result")){e.responseKind=r;continue}if(n==="attachments"&&Array.isArray(r)){(!Array.isArray(e.attachments)||e.attachments.length===0)&&(e.attachments=r);continue}(e[n]===void 0||e[n]===null||e[n]==="")&&(e[n]=r)}}return e}function ic(e=[],t=[]){let s=[],n=new Map,r=new Map;for(let i of[...e,...t]){if(!i)continue;let o=br(i),a=i.type==="user"&&i.clientMessageId?String(i.clientMessageId):null;if(o&&n.has(o)){yo(n.get(o),i);continue}if(a&&r.has(a)){let l=r.get(a);yo(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 oc(e,t,s){return!e||e!==t?!1:!s?.loaded&&!s?.loading}function ac(e,t){return!!t&&!!e?.loaded&&!e?.loading&&Number.isFinite(e?.latestSeq)}function bo({sessionState:e,hasCachedSessionRows:t,force:s=!1}={}){return e?.loading?!1:s?!e?.loaded:e?.loaded?!1:!t}function Tm(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"&&br(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,wn(e,t,o),!0):!1}function wr(e,t,s){if(!t)return;let n={...s,id:s.dbMessageId||s.id||Date.now().toString()+Math.random().toString(36).substr(2,9),timestamp:xm(s)};vo(e,t)&&!n.sessionId&&(n.sessionId=e._currentYeaftSessionId||e.yeaftActiveSessionFilter||Am),vo(e,t)&&(!n.vpId&&e._currentYeaftVpId&&(n.vpId=e._currentYeaftVpId),!n.turnId&&e._currentYeaftTurnId&&(n.turnId=e._currentYeaftTurnId),wn(e,t,n)),e.messagesMap[t]||(e.messagesMap[t]=[]);let r=br(s);if(r){let i=e.messagesMap[t].find(o=>br(o)===r);if(i)return yo(i,n),t===e.yeaftConversationId&&e.messagesMap[t].sort((o,a)=>o.timestamp-a.timestamp),i}return e.messagesMap[t].push(n),rc(e.messagesMap[t]),t===e.yeaftConversationId&&e.messagesMap[t].sort((i,o)=>i.timestamp-o.timestamp),n}function lc(e,t,s,n={}){if(!t||!s)return;e.messagesMap[t]||(e.messagesMap[t]=[]);let r=e.messagesMap[t];if(Tm(e,t,n,s))return;let i=e._currentYeaftTurnId;if(i){for(let a=r.length-1;a>=0;a--)if(r[a].turnId===i&&r[a].type==="assistant"&&r[a].isStreaming){if(wn(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}wr(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(wn(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 wr(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 cc(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())),wn(e,t,o),o.type==="user")break}}function dc(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 uc(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 ns(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 pc(e){return{id:e.id,dbMessageId:e.id,timestamp:e.created_at}}function fc(e){return e?e.message_type==="tool_use"&&!Mm.has(e.tool_name)?{...pc(e),type:"tool-use",toolName:e.tool_name||"unknown",hasResult:!0,isHistory:!0,startTime:e.created_at||0}:wo(e):null}function wo(e){if(!e)return null;let t=pc(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 Am,Mm,Ds=F(()=>{ho();Am="grp_default";Mm=new Set(["TodoWrite","AskUserQuestion"])});function rs(e,t){return e._closedAt?.[t]?Date.now()-e._closedAt[t]<3e4:!1}function Ls(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={});let s=()=>{if(!e.processingConversations[t])return;let r=e.conversations.find(o=>o.id===t);e.sendWsMessage({type:"ping_session",conversationId:t,agentId:r?.agentId});let i=setTimeout(()=>{e.processingConversations[t]&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[t]={status:"agent-offline"})},1e4);e._pongTimeouts||(e._pongTimeouts={}),e._pongTimeouts[t]=i},n=setTimeout(()=>{e.processingConversations[t]&&(s(),e._processingWatchdogs[t]=setInterval(()=>{if(!e.processingConversations[t]){Ae(e,t);return}s()},3e4))},45e3);e._processingWatchdogs[t]=n}function kr(e,t){e.processingConversations[t]&&e._processingWatchdogs?.[t]&&(e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._yeaftWatchdogConvs?.has(t)?kn(e,t):Ls(e,t))}function Ae(e,t){e._processingWatchdogs?.[t]&&(clearTimeout(e._processingWatchdogs[t]),clearInterval(e._processingWatchdogs[t]),delete e._processingWatchdogs[t]),e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),e.sessionHealth?.[t]&&delete e.sessionHealth[t],e._autoRefreshed?.[t]&&delete e._autoRefreshed[t],e._yeaftWatchdogConvs?.delete(t)}function gc(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){let s=e.conversations.find(n=>n.id===t);e.sendWsMessage({type:"refresh_conversation",conversationId:t,agentId:s?.agentId}),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let n=e.executionStatusMap[t];n&&(n.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},1e4)}},9e4)}function kn(e,t){Ae(e,t),e._processingWatchdogs||(e._processingWatchdogs={}),e._yeaftWatchdogConvs||(e._yeaftWatchdogConvs=new Set),e._yeaftWatchdogConvs.add(t),e._processingWatchdogs[t]=setTimeout(()=>{if(e.processingConversations[t]){delete e.processingConversations[t];let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t)}delete e._processingWatchdogs[t]},15e4)}var Nt=F(()=>{});function ko(e,t){return t&&Array.isArray(e?._yeaftRetiredConversationIdsByAgent?.[t])?e._yeaftRetiredConversationIdsByAgent[t]:[]}function $s(e,t,s){return!t||!s?!1:ko(e,t).includes(s)}function So(e,t){let s=e?._yeaftRetiredConversationTargetsByAgent?.[t];return s&&typeof s=="object"?s:{}}function mc(e,t,s){if(!t||!s)return null;let n=So(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 Sn(e,t,s,n=null){if(!t||!s)return;let r=ko(e,t).filter(a=>a!==s).concat(s).slice(-8);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent||{},[t]:r};let i=So(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 Io(e,t,s){if(!t||!s||!e?._yeaftRetiredConversationIdsByAgent)return;let n=ko(e,t).filter(i=>i!==s);e._yeaftRetiredConversationIdsByAgent={...e._yeaftRetiredConversationIdsByAgent,[t]:n};let r={...So(e,t)};delete r[s],e._yeaftRetiredConversationTargetsByAgent={...e._yeaftRetiredConversationTargetsByAgent||{},[t]:r}}var Sr=F(()=>{});function _m(e,t,s){let n=e.messagesMap?.[t]||[],r=e.messagesMap?.[s]||[];e.messagesMap||(e.messagesMap={}),e.messagesMap[s]=ic(r,n).sort((i,o)=>(i.timestamp||0)-(o.timestamp||0))}function Em(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 Ir(e,t){return!!e&&Object.prototype.hasOwnProperty.call(e,t)}function Vs(e,t,s,{removeSource:n}){Ir(e,t)&&(Ir(e,s)||(e[s]=n?e[t]:Em(e[t])),n&&delete e[t])}function mt(e,t,s=null){if(!t)return null;let n=e?._yeaftPendingConversationPromotions?.[t]||null;return!n?.sourceConversationId||!n.targetConversationId||s&&n.targetConversationId!==s?null:n}function Cr(e,t,s,n){return!t||!s||!n||s===n?!1:(e._yeaftPendingConversationPromotions={...e._yeaftPendingConversationPromotions||{},[t]:{sourceConversationId:s,targetConversationId:n}},!0)}function In(e,t,s=null){let n=mt(e,t,s);if(!n)return null;let r={...e._yeaftPendingConversationPromotions||{}};return delete r[t],e._yeaftPendingConversationPromotions=r,n}function Cn(e,t,s){let n=mt(e,t);return!n||!s||n.targetConversationId===s?null:(ht(e,n.targetConversationId,s,{removeSource:!0}),Sn(e,t,n.targetConversationId,s),Cr(e,t,n.sourceConversationId,s),n)}function ht(e,t,s,{removeSource:n=!0}={}){if(!t||!s||t===s)return!1;_m(e,t,s),Vs(e.processingConversations,t,s,{removeSource:n}),Vs(e.executionStatusMap,t,s,{removeSource:n}),Vs(e.refreshingSessionMap,t,s,{removeSource:n}),Vs(e._closedAt,t,s,{removeSource:n}),Vs(e._autoRefreshed,t,s,{removeSource:n}),Vs(e.sessionHealth,t,s,{removeSource:n}),e._turnCompletedConvs?.has(t)&&(e._turnCompletedConvs.add(s),n&&e._turnCompletedConvs.delete(t));let r=!!e._yeaftWatchdogConvs?.has(t),i=!!e._processingWatchdogs?.[t];if(n&&i&&Ae(e,t),n&&e._pongTimeouts?.[t]&&(clearTimeout(e._pongTimeouts[t]),delete e._pongTimeouts[t]),n&&(i||r)&&!!e.processingConversations?.[s])if(e._processingWatchdogs?.[s])e._yeaftWatchdogConvs?.add(s);else{let a=Ir(e.sessionHealth,s),l=e.sessionHealth?.[s],c=Ir(e._autoRefreshed,s),d=e._autoRefreshed?.[s];kn(e,s),a&&(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[s]=l),c&&(e._autoRefreshed||(e._autoRefreshed={}),e._autoRefreshed[s]=d)}return n&&e.messagesMap&&delete e.messagesMap[t],!0}var Co=F(()=>{Ds();Sr();Nt()});function Ar(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 Ao=F(()=>{});function xo(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function Dm(){return Date.now()}function Lm(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`pt_${crypto.randomUUID()}`:`pt_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`}function $m(e,t=160){return typeof e!="string"?e:e.length>t?`${e.slice(0,t)}...[truncated]`:e}function Vm(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"?$m(n):n);return t}function An(){return Lm()}function Xe(e,t={}){!e||!t.traceId||(Array.isArray(e._perfTraceQueue)||(e._perfTraceQueue=[]),e._perfTraceQueue.push({traceId:t.traceId,source:"web",phase:t.phase||"unknown",at:Dm(),monotonicMs:xo(),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:Vm(t.detail)}),e._perfTraceQueue.length>200&&e._perfTraceQueue.splice(0,e._perfTraceQueue.length-200),Fm(e))}function Fm(e){!e||e._perfTraceFlushTimer||(e._perfTraceFlushTimer=setTimeout(()=>Om(e),250))}function Om(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 xr(e,t={}){if(typeof requestAnimationFrame!="function")return;let s=xo();requestAnimationFrame(()=>{requestAnimationFrame(()=>{Xe(e,{...t,phase:t.phase||"render.next_paint",durationMs:xo()-s})})})}var To=F(()=>{});function Pe(e,t){let s=t==null?"__all__":String(t);return e?`${e}${s}`:s}var Tr=F(()=>{});function Mo(e){return typeof e=="string"&&e?e:null}function Fs(e,t){return e?.yeaftSessionHistoryState?.[t]||null}function xn(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 vc(e,{agentId:t,sessionId:s,mode:n="recent",preserveLoaded:r=!1,latestSeq:i=null}={}){if(!t||!s)return null;let o=Pe(t,s),a=Fs(e,o)||{},l=Number(a.generation||0)+1,c=`yeaft_history_${l}_${crypto.randomUUID()}`,d={...a,loaded:!!a.loaded,loading:!0,error:null,requestId:c,generation:l,mode:n,requestedAt:Date.now(),latestSeq:Number.isFinite(i)?i:a.latestSeq??null};return delete d.completionSeen,r||(d.syncingAfterSeq=null,a.loaded||(d.hasMore=!1,d.oldestSeq=null,d.count=0)),e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[o]:d},Tn(e),{sessionKey:o,requestId:c,generation:l,state:d}}function Po(e,t={}){let s=t.sessionId??t.groupId??null;if(!s)return!1;let n=t.agentId||e?.yeaftSessionAgentById?.[s]||null,r=Pe(n,s),i=Fs(e,r),o=Mo(t.requestId);if(!i)return o===null;let a=Mo(i.requestId);return o?o===a:a===null}function yc(e,t={},s={},n="chunk"){if(!Po(e,t))return null;let r=t.sessionId??t.groupId??null,i=t.agentId||e?.yeaftSessionAgentById?.[r]||null,o=Pe(i,r),a=Fs(e,o)||{},l=Mo(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},Tn(e),d}function bc(e,{agentId:t,sessionId:s,requestId:n,error:r="history_load_failed"}={}){if(!t||!s||!n)return!1;let i=Pe(t,s),o=Fs(e,i);return!o||o.requestId!==n||!o.loading?!1:(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState||{},[i]:{...o,loading:!1,error:r,requestId:null,completedAt:Date.now()}},Tn(e),!0)}function Tn(e){let{sessionKey:t}=xn(e),s=t?Fs(e,t):null;return e.yeaftLoadingMoreHistory=!!s?.loading,e.yeaftHistoryLoadError=s?.error||null,e.yeaftHasMoreHistory=!!s?.hasMore,e.yeaftOldestLoadedSeq=Number.isFinite(s?.oldestSeq)?s.oldestSeq:null,s}function Ro(e){let{sessionKey:t}=xn(e);return t?Fs(e,t):null}var hc,_o=F(()=>{Tr();hc=15e3});function Ic(e){return e.filter(t=>!(t.type==="user"&&(!t.content||!t.content.trim())))}function wc(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 Hm(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 qm(e){return Array.isArray(e?.toolCalls)?e.toolCalls.filter(t=>t?.name!=="TodoWrite").length:Number(e?.toolSummaryCount||0)||0}function Nm(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 Bm(e,t){return e.speakerVpId||e.vpId||e.vp_id||e.authorVpId||e.authorVP||Nm(t)}function Mr(e){return e&&(e.messageId||e.id)?e.messageId||e.id:null}function Wm(e){e.sort((t,s)=>(t.timestamp||0)-(s.timestamp||0))}function Um(e,t){if(!e||!t||e.type!=="assistant"||t.type!=="assistant"||(e.sessionId??null)!==(t.sessionId??null))return!1;let s=e.speakerVpId||e.vpId||"",n=t.speakerVpId||t.vpId||"";if(s&&n&&s!==n)return!1;let r=e.threadId||"",i=t.threadId||"";if(r&&i&&r!==i||!(e.isStreaming||e.isHistory!==!0)||t._hasPersistedTurnId!==!0)return!1;let a=e.turnId||"",l=t.turnId||"";if(!a||!l||a!==l)return!1;let c=typeof e.content=="string"?e.content:"",d=typeof t.content=="string"?t.content:"";return!!c&&!!d&&(d.startsWith(c)||c.startsWith(d))}function Eo(e,t){let s=new Map,n=new Map;e.forEach((i,o)=>{let a=Mr(i);a&&s.set(a,o),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,o)});let r=0;for(let i of t){let o=Mr(i),a=o&&s.has(o)?s.get(o):null;if(a===null&&i?.type==="user"&&i.clientMessageId&&n.has(i.clientMessageId)&&(a=n.get(i.clientMessageId)),a===null&&i?.type==="assistant"&&(a=e.findIndex(l=>Um(l,i))),a!==null&&a>=0){let l=Mr(e[a]);e[a]={...e[a],...i},o&&s.set(o,a),l&&l!==o&&s.get(l)===a&&s.delete(l),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,a)}else o&&s.set(o,e.length),i?.type==="user"&&i.clientMessageId&&n.set(i.clientMessageId,e.length),e.push(i),r+=1}return Wm(e),r}function Pr(e){return e?e.sessionId??e.groupId??null:null}function jm(e){return!e||e.type!=="user"||!e.clientMessageId?!1:Mr(e)===e.clientMessageId}function zm(e,t,s){let n=e.some(o=>o&&(s==null||Pr(o)===s));if(t.length===0&&n)return{insertedRows:0,preservedEmpty:!0};let r=t.reduce((o,a)=>Math.max(o,a?.timestamp||0),0),i=e.filter(o=>o?s!=null&&Pr(o)!==s||o.isStreaming||o.type==="tool-use"&&o.toolName==="AskUserQuestion"&&(o.askAnswered||o.askPending||o.askExpired)||jm(o)?!0:r>0&&(o.timestamp||0)>r:!1);return e.splice(0,e.length,...i),Eo(e,t),{insertedRows:t.length,preservedEmpty:!1}}function Km(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 Ym(e,t){let s=typeof e.yeaftConversationId=="string"?e.yeaftConversationId:"";return s.startsWith(`yeaft-local-${t}-`)||/^yeaft-local-\d/.test(s)?s:null}function Gm(e,t,s,n){let r=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if(!r||!n||e.currentView!=="yeaft")return;let i=xn(e);if(i.sessionId!==(s||null)||i.agentId&&i.agentId!==r)return;let o=e.yeaftConversationId||null;if($s(e,r,n)){let d=e.yeaftConversationIdsByAgent?.[r]||null;d&&d!==n&&ht(e,n,d,{removeSource:n!==e.yeaftConversationId});return}let a=mt(e,r);a&&a.targetConversationId!==n&&Cn(e,r,n);let l=mt(e,r,n);if(l&&(ht(e,l.sourceConversationId,n,{removeSource:!0}),In(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=Ym(e,r);c&&(ht(e,c,n,{removeSource:!0}),e.yeaftConversationIdsByAgent={...e.yeaftConversationIdsByAgent||{},[r]:n},e.yeaftConversationId=n,e.activeConversations=[n])}function Bt(e,t){let s=e.messagesMap[t]||[];for(let n of s)n.type==="tool-use"&&!n.hasResult&&(n.hasResult=!0,n.toolName==="AskUserQuestion"&&!n.askAnswered&&!n.selectedAnswers&&(n.isHistory=!0,n.askRequestId=null))}function Cc(e,t){gt(e);let s=e.agents.find(r=>r.id===t.agentId);e.conversations=e.conversations.filter(r=>r.id!==t.conversationId);let n=t.provider||"claude-code";if(e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:null,createdAt:Date.now(),processing:!1,connecting:n!=="claude-code",type:"chat",provider:n,capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let r=e._pendingPaneId;if(e._pendingPaneId=null,r){let i=e.panels.find(o=>o.id===r);i&&(i.conversationId=t.conversationId)}else{let i=e.panels.find(o=>!o.conversationId);i&&(i.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convCreated",{agent:s?.name||t.agentId,workDir:t.workDir})}),e.saveOpenSessions()}function Ac(e,t){gt(e);let s=e.agents.find(n=>n.id===t.agentId);if(e.conversations=e.conversations.filter(n=>n.id!==t.conversationId&&!(n.claudeSessionId&&n.claudeSessionId===t.claudeSessionId)),e.conversations.push({id:t.conversationId,agentId:t.agentId,agentName:s?.name||t.agentId,workDir:t.workDir,claudeSessionId:t.claudeSessionId,createdAt:Date.now(),processing:!1,connecting:(t.provider||"claude-code")!=="claude-code",type:"chat",provider:t.provider||"claude-code",capabilities:t.capabilities||null,disallowedTools:t.disallowedTools??null}),e.currentAgent=t.agentId,e.currentAgentInfo=s,e.panels.length>1){let n=e._pendingPaneId;if(e._pendingPaneId=null,n){let r=e.panels.find(i=>i.id===n);r&&(r.conversationId=t.conversationId)}else{let r=e.panels.find(i=>!i.conversationId);r&&(r.conversationId=t.conversationId)}e.activeConversations.includes(t.conversationId)||e.activeConversations.push(t.conversationId)}else e.activeConversations=[t.conversationId];if(e.currentWorkDir=t.workDir,e.messagesMap[t.conversationId]=[],e._pendingSessionTitle&&(e.conversationTitles[t.conversationId]=e._pendingSessionTitle,e._pendingSessionTitle=null),e.sendWsMessage({type:"select_conversation",conversationId:t.conversationId}),e.addMessage({type:"system",content:Ee("store.convResumed",{agent:s?.name||t.agentId,sessionId:t.claudeSessionId?t.claudeSessionId.slice(0,8)+"...":""})}),t.dbMessages&&t.dbMessages.length>0){let n=Ic(t.dbMessages.map(o=>e.formatDbMessageForHistoryHydration(o)).flat().filter(Boolean)),r=mo(n),i=e.messagesMap[t.conversationId]||[];for(let o of r)i.push(o)}e.hasMoreMessages=!!t.hasMoreMessages,e.chatSessionState[t.conversationId]={lastSeenDbId:ns(e.messagesMap[t.conversationId]),hasMoreOlder:!!t.hasMoreMessages},e.saveOpenSessions()}function Do(e,t){e.conversations=e.conversations.filter(n=>n.id!==t.conversationId),delete e.messagesMap[t.conversationId],delete e.chatSessionState[t.conversationId],delete e.conversationTitles[t.conversationId],delete e.customConversationTitles[t.conversationId],delete e.processingConversations[t.conversationId],e._closedAt&&delete e._closedAt[t.conversationId],Ae(e,t.conversationId),delete e.executionStatusMap[t.conversationId],delete e.subagents[t.conversationId],window.dispatchEvent(new CustomEvent("conversation-deleted",{detail:{conversationId:t.conversationId}}));let s=e.activeConversations.indexOf(t.conversationId);s>=0&&(e.activeConversations.splice(s,1),e.activeConversations.length===0&&e.addMessage({type:"system",content:Ee("chat.session.closed")}));for(let n of e.panels)n.conversationId===t.conversationId&&(n.conversationId=null);e.saveOpenSessions()}function xc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(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 Tc(e,t){let s=t.conversationId;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(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 Mc(e,t){if(t.conversationId){if(t.isProcessing&&!rs(e,t.conversationId)&&!e._turnCompletedConvs?.has(t.conversationId))e.processingConversations[t.conversationId]=!0;else if(e.processingConversations[t.conversationId]){delete e.processingConversations[t.conversationId],Ae(e,t.conversationId);let s=e.executionStatusMap[t.conversationId];s&&(s.currentTool=null),e.finishStreamingForConversation(t.conversationId)}}}function Pc(e,t){let s=t.conversationId||e.currentConversation;if(s){delete e.processingConversations[s],Ae(e,s),e._closedAt||(e._closedAt={}),e._closedAt[s]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(s);let n=e.executionStatusMap[s];n&&(n.currentTool=null),e.finishStreamingForConversation(s),Bt(e,s)}}function Rc(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=mo(Ic((t.messages||[]).map(a=>e.formatDbMessageForHistoryHydration(a)).flat().filter(Boolean)));if(i.length>0){let a=n.find(l=>l.dbMessageId);if(a&&i[0].dbMessageId&&i[i.length-1].dbMessageId<a.dbMessageId){let l=n.indexOf(a);e.debug,n.splice(l,0,...i)}else{e.debug;for(let l of i)if(!(l.dbMessageId&&n.some(c=>c.dbMessageId===l.dbMessageId))){if(l.dbMessageId&&(l.type==="assistant"||l.type==="user")){let c=null;if(l.type==="user"?c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&Ar(d,l)):c=n.find(d=>!d.dbMessageId&&!d.isStreaming&&d.type==="assistant"&&d.content===l.content),c){c.dbMessageId=l.dbMessageId,c.id=l.id,l.timestamp&&(c.timestamp=l.timestamp),l.clientMessageId&&!c.clientMessageId&&(c.clientMessageId=l.clientMessageId);continue}}n.push(l)}}}r||(e.hasMoreMessages=t.hasMore??!1),gt(e);let o=e.chatSessionState[t.conversationId]?.hasMoreOlder;e.chatSessionState[t.conversationId]={lastSeenDbId:ns(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 _c(e,t){let s=t.sessionId??null,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null,r=t.conversationId||n&&e.yeaftConversationIdsByAgent?.[n]||e.yeaftConversationId;if(!r||!s||!Array.isArray(t.messages))return null;e.messagesMap[r]||(e.messagesMap[r]=[]);let{formatted:i}=Ec(t.messages,s,"window",e.messagesMap[r]);return Eo(e.messagesMap[r],i),r}function kc(e){return e?.toolId?[Pr(e)??"",e.vpId||e.speakerVpId||"",e.turnId||"",e.threadId||"main",e.toolId].join("\0"):null}function Sc(e,t,s){return e.toolName="AskUserQuestion",e.toolId=t.toolCallId,e.toolInput={questions:s},e.askQuestions=s,e.askRequestId=null,e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.hasResult=!0,e.isHistory=!0,t.status==="answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers,e.askExpired=!1):(e.askAnswered=!1,e.selectedAnswers=null,e.askExpired=!0),e}function Qm(e,t){return(e||[]).find(s=>s?.type==="tool-use"&&(s.toolName==="AskUser"||s.toolName==="AskUserQuestion")&&s.toolId===t.toolCallId&&Pr(s)===t.sessionId&&(s.vpId||s.speakerVpId||"")===(t.vpId||"")&&(s.turnId||"")===(t.turnId||"")&&(s.threadId||"main")===(t.threadId||"main"))||null}function Ec(e,t,s,n){let r=new Set((n||[]).map(l=>l&&(l.messageId||l.id)).filter(Boolean)),i=new Set,o=[],a=0;for(let l of e){if(!l||l._reflection||l.internal||l.systemOnly||l.systemOnlyMessage||Km(l.content))continue;let c=l.id||l.messageId||null,d=l.clientMessageId||null;if(!(c&&i.has(c))&&!(c&&s!=="recent"&&r.has(c))){if(c&&i.add(c),l.role==="user"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null;o.push({...c?{id:c,messageId:c}:{},type:"user",content:l.content,timestamp:wc(l),sessionId:f,turnId:l.turnId||u,...d?{clientMessageId:d}:{},...Array.isArray(l.attachments)&&l.attachments.length>0?{attachments:l.attachments}:{},...l.quote?{quote:l.quote}:{},isStreaming:!1})}else if(l.role==="assistant"){a+=1;let u=c||l.messageId||l.turnId||null,f=l.sessionId??l.groupId??t??null,p=Bm(l,f),g=wc(l),b=!!l.turnId,h=l.turnId||u,A=typeof l.content=="string"?l.content:l.content||"",w=Array.isArray(l.todos)?l.todos:Hm(l.toolCalls);(typeof A!="string"||A.trim())&&o.push({...c?{id:c,messageId:c}:{},type:"assistant",content:A,timestamp:g,sessionId:f,turnId:h,_hasPersistedTurnId:b,...p?{vpId:p,speakerVpId:p}:{},...l.responseKind==="progress"||l.responseKind==="result"?{responseKind:l.responseKind}:{},...l.incomplete===!0?{incomplete:!0}:{},...typeof l.stopReason=="string"&&l.stopReason?{stopReason:l.stopReason}:{},isStreaming:!1,isHistory:!0}),Array.isArray(w)&&w.length>0&&o.push({...c?{id:`${c}:todos`,messageId:`${c}:todos`}:{},type:"tool-use",toolName:"TodoWrite",toolInput:{todos:w},timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0,hasResult:!0});for(let y of Array.isArray(l.images)?l.images:[])y?.assetId&&o.push({id:`${c||u||h}:image:${y.assetId}`,messageId:`${c||u||h}:image:${y.assetId}`,type:"chat-image",...y,timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0});for(let y of Array.isArray(l.askUserResults)?l.askUserResults:[]){if(!y?.toolCallId||y.status!=="answered"&&y.status!=="expired")continue;let m=[{question:typeof y.question=="string"?y.question:"",options:(Array.isArray(y.options)?y.options:[]).filter(L=>typeof L=="string").map(L=>({label:L,description:""})),multiSelect:!1}],v={toolCallId:y.toolCallId,sessionId:f,vpId:p||"",turnId:h||"",threadId:l.threadId||"main"},E=Qm(n,v);if(E){Sc(E,y,m);continue}let V=Sc({id:`${c||u||h}:ask:${y.toolCallId}`,messageId:`${c||u||h}:ask:${y.toolCallId}`,type:"tool-use",timestamp:g,sessionId:f,turnId:h,threadId:v.threadId,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1},y,m),U=kc(V);(!U||!o.some(L=>kc(L)===U))&&o.push(V)}let S=qm(l);S>0&&o.push({...c?{id:`${c}:tool-summary`,messageId:`${c}:tool-summary`,persistedMessageId:c}:{},type:"tool-summary",count:S,omittedCount:S,source:"history",timestamp:g,sessionId:f,turnId:h,...p?{vpId:p,speakerVpId:p}:{},isStreaming:!1,isHistory:!0})}}}return{formatted:o,acceptedHistoryMessages:a}}function Dc(e,t){let s=t.sessionId!=null?t.sessionId:t.groupId,n=t.agentId||s&&e.yeaftSessionAgentById?.[s]||null;if($s(e,n,t.conversationId)){let v=e.yeaftConversationIdsByAgent?.[n]||null;if(!v||v===t.conversationId)return;ht(e,t.conversationId,v,{removeSource:t.conversationId!==e.yeaftConversationId}),t={...t,conversationId:v}}if(t.requestId&&typeof e.isCurrentYeaftHistoryResponse=="function"&&!e.isCurrentYeaftHistoryResponse(t))return;let r=t.mode==="recent"||t.mode==="delta"?t.mode:"older",i=Array.isArray(t.messages)?t.messages:[];t.perfTraceId&&Xe(e,{traceId:t.perfTraceId,phase:"history.chunk_received",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,bytes:(()=>{try{return JSON.stringify(t).length}catch{return null}})(),detail:{mode:r,rawCount:i.length}});let o=t.agentId||(s&&e.yeaftSessionAgentById?e.yeaftSessionAgentById[s]:null),a=o&&e.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[o]:null,l=t.conversationId||a||e.yeaftConversationId;if(!l){e.yeaftLoadingMoreHistory=!1;return}Gm(e,t,s,l),e.messagesMap[l]||(e.messagesMap[l]=[]);let{formatted:c,acceptedHistoryMessages:d}=Ec(i,s,r,e.messagesMap[l]),u=0,f=!1;if(r==="recent"){let v=zm(e.messagesMap[l],c,s??null);u=v.insertedRows,f=v.preservedEmpty}else if(c.length>0)if(r==="older"){if(e.messagesMap[l].splice(0,0,...c),u=c.length,typeof e.expandYeaftMessageWindow=="function"){let v=e.yeaftActiveSessionFilter?s??null:null;e.expandYeaftMessageWindow(v,t.turns||10)}}else u=Eo(e.messagesMap[l],c);let p=Pe(t.agentId||null,s),g=e.yeaftSessionHistoryState?.[p]||{},b=typeof t.latestSeq=="number"?t.latestSeq:g.latestSeq??null,h=r==="delta"?{...g,loaded:!0,loading:!1,latestSeq:b,syncingAfterSeq:null,count:(g.count||0)+u}:{...f?g:{},loaded:!0,loading:!1,hasMore:f?!!g.hasMore:!!t.hasMore,oldestSeq:f?Number.isFinite(g.oldestSeq)?g.oldestSeq:e.yeaftOldestLoadedSeq:typeof t.oldestSeq=="number"?t.oldestSeq:e.yeaftOldestLoadedSeq,count:r==="older"?(g.count||0)+u:f?g.count||0:d,latestSeq:f&&!Number.isFinite(t.latestSeq)?g.latestSeq??null:b,syncingAfterSeq:null};t.requestId&&typeof e.finishYeaftHistoryLoad=="function"?e.finishYeaftHistoryLoad(t,h,"chunk"):e.yeaftSessionHistoryState&&(e.yeaftSessionHistoryState={...e.yeaftSessionHistoryState,[p]:h});let A=xn(e),w=A.sessionId===(s||null),S=!t.agentId||!A.agentId||t.agentId===A.agentId,y=w&&S,m=Pe(null,A.sessionId);if(t.perfTraceId&&(Xe(e,{traceId:t.perfTraceId,phase:"history.chunk_applied",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,formattedCount:c.length,insertedRows:u,acceptedHistoryMessages:d,preservedEmptyRecent:f}}),xr(e,{traceId:t.perfTraceId,phase:"history.next_paint",agentId:t.agentId||null,sessionId:s||null,messageType:t.type,detail:{mode:r,insertedRows:u}})),y)e.yeaftHasMoreHistory=h.hasMore,typeof t.oldestSeq=="number"&&(e.yeaftOldestLoadedSeq=t.oldestSeq),e.yeaftLoadingMoreHistory=!1;else if(e.yeaftLoadingMoreHistory){let v=e.yeaftSessionHistoryState?.[A.sessionKey]||e.yeaftSessionHistoryState?.[m]||null;e.yeaftLoadingMoreHistory=!!v?.loading}}var Rr=F(()=>{Nt();Co();Sr();ss();Ao();Ds();ho();xt();To();_o();Tr()});function Lc(e,t){if(e.promoteYeaftHistoryOutlineRow?.(t))return;let s=t?.sessionId??t?.groupId??e._currentYeaftSessionId??null;s&&e.invalidateYeaftHistoryOutline?.(s)}function Xm(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 Lo(e,t){return e.executionStatusMap[t]||(e.executionStatusMap[t]={currentTool:null,toolHistory:[],lastActivity:null}),e.executionStatusMap[t]}function $c(e,t,s){if(!t)return;let n=Lo(e,t);if(n.lastActivity=Date.now(),kr(e,t),s.type==="system"){if(s.subtype==="init"){let r=e.conversations.find(i=>i.id===t);r&&r.connecting&&(r.connecting=!1);return}s.message&&e.addMessageToConversation(t,{type:"system",content:typeof s.message=="string"?s.message:JSON.stringify(s.message,null,2)});return}if(s.type==="assistant"){let r=s.message?.content;if(!r)return;let i=e.messagesMap[t]||[];for(let o of i)o.type==="tool-use"&&!o.hasResult&&(o.hasResult=!0);for(let o of n.toolHistory)o.status==="running"&&(o.status="done");if(n.currentTool=null,typeof r=="string"){e.appendToAssistantMessageForConversation(t,r,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null});return}if(!Array.isArray(r))return;if(r.length===0){e.finishStreamingForConversation(t);return}for(let o of r)o.type==="text"?e.appendToAssistantMessageForConversation(t,o.text,{id:s.message?.id||s.message?.messageId||null,ts:s.ts||s.message?.ts||s.message?.time||null,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="image_asset"&&o.image?e.addMessageToConversation(t,{type:"chat-image",...o.image,sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,speakerVpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_summary"?e.addMessageToConversation(t,{type:"tool-summary",count:Number(o.count||o.omittedCount||0)||0,omittedCount:Number(o.omittedCount||o.count||0)||0,source:o.source||"history",isHistory:o.source!=="live",sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}):o.type==="tool_use"&&(e.finishStreamingForConversation(t,{completeLifecycle:!1}),n.currentTool={name:o.name,input:o.input,startTime:Date.now()},n.toolHistory.unshift({name:o.name,input:o.input,timestamp:Date.now(),status:"running"}),n.toolHistory.length>20&&n.toolHistory.pop(),e.addMessageToConversation(t,{type:"tool-use",toolId:o.id||o.tool_use_id||null,toolName:o.name,toolInput:o.input,startTime:Date.now(),sessionId:e._currentYeaftSessionId||null,vpId:e._currentYeaftVpId||null,turnId:e._currentYeaftTurnId||null,threadId:e._currentYeaftThreadId||null}))}else if(s.type==="user"){let r=s.internal===!0||s.message?.internal===!0||s.userAuthored===!1||s.message?.userAuthored===!1,i=s.message?.content,o=Xm(i);if(typeof o=="string"&&(o.includes("<local-command-caveat>")||o.includes("<command-name>")))return;if(typeof o=="string"&&o.includes("<local-command-stdout>")){let l=o.match(/<local-command-stdout>([\s\S]*?)<\/local-command-stdout>/);if(l){e.appendToAssistantMessageForConversation(t,l[1].trim()),e.finishStreamingForConversation(t);return}}let a=[];if(s.tool_use_result)a=Array.isArray(s.tool_use_result)?s.tool_use_result:[s.tool_use_result];else if(s.message?.content){let l=s.message.content;a=(Array.isArray(l)?l:[]).filter(d=>d.type==="tool_result")}if(a.length>0){let l=e.messagesMap[t]||[];for(let c of a){if(n.toolHistory.length>0){let p=n.toolHistory.findIndex(g=>g.status==="running");p>=0&&(n.toolHistory[p].status="done")}let d=c.tool_use_id||c.toolUseId||c.tool_call_id||c.toolCallId||null,u=c.content||c,f=!1;if(d){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&l[p].toolId===d){l[p].hasResult=!0,l[p].toolResult=c.is_update&&l[p].toolResult?`${l[p].toolResult}
|
|
2
2
|
|
|
3
|
-
${u}`:u,f=!0;break}}if(!f){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&!l[p].hasResult){l[p].hasResult=!0,l[p].toolResult=u;break}}}n.currentTool=null}else if(!r&&(typeof o=="string"&&o.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let l=s.message?.clientMessageId||s.clientMessageId||null,c={type:"user",content:o,clientMessageId:l},d=e.messagesMap[t]||[];if(d.some(f=>Ar(f,c))){if(l){for(let f=d.length-1;f>=0;f--)if(d[f].type==="user"&&d[f].clientMessageId===l){s.dbMessageId&&!d[f].dbMessageId&&(d[f].dbMessageId=s.dbMessageId),s.message?.id&&!d[f].messageId&&(d[f].id=s.message.id,d[f].messageId=s.message.id),s.ts&&!d[f].ts&&(d[f].ts=s.ts),Lc(e,d[f]);break}}}else{let f=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:o,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...l?{clientMessageId:l}:{}});Lc(e,f)}}}else if(s.type==="result"){delete e.processingConversations[t],Ae(e,t);let r=e.conversations.find(c=>c.id===t);r&&r.connecting&&(r.connecting=!1);let i=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let c=Object.entries(e.activeVpTurns||{}).find(([,d])=>(d?.turnId===e._currentYeaftTurnId||!d?.turnId&&d===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!d?.agentId||d.agentId===e._currentYeaftAgentId));if(c){let[d,u]=c,{[d]:f,...p}=e.activeVpTurns;!i&&u?.sessionId&&(i=u.sessionId),e.activeVpTurns=p}}if(i&&e._currentYeaftVpId&&e.vpStatuses){let c=e._currentYeaftTurnId||null,d={...e.vpStatuses||{}},u=!1;for(let[f,p]of Object.entries(d))!p||p.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&p.agentId&&p.agentId!==e._currentYeaftAgentId||(p.sessionId||p.groupId||null)!==i||c&&p.turnId&&p.turnId!==c||(d[f]={...p,state:"idle",turnId:null,since:Date.now()},u=!0);u&&(e.vpStatuses=d)}i&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(i,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),n.currentTool=null,Bt(e,t);let o=e.messagesMap[t]||[],a=s.result_text||"";if(typeof a=="string"&&a.trim()){let c=!1;for(let d=o.length-1;d>=0;d--){if(o[d].type==="assistant"){c=!0;break}if(o[d].type==="user")break}c||e.appendToAssistantMessageForConversation(t,a.trim())}e.finishStreamingForConversation(t),!e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null)&&i&&e.invalidateYeaftHistoryOutline?.(i),e.sweepStaleStreamingForConversation(t)}}var Vc=F(()=>{Nt();Rr();Ao()});function rs(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function _r(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return rs(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return rs(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?rs(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=rs(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]=rs(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]=rs(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(rs(t.body.messagesAppend)||[])}s.body=n}return s}function Fc(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:_r(e??null,t.rawRequestDelta)}function Mn(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 Jm(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 Oc(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=Jm(i);for(let l of o)t+=Mn(l);for(let l of a)s+=Mn(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Mn(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Mn(String(i.name||"")),i.input!==void 0))try{r+=Mn(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function $o(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 Hc(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 Vo=F(()=>{});function dt(e,t){return!e||!t?"":`${e}${t}`}function Pn(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 Fo(e){return e?`${e}`:""}function Oo(e,t){return!e||!t?"":`${e}${t}`}var Rn=F(()=>{});function eh(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 qc(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 Nc(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=e._hasHandledAgentList===!0,r=e.currentAgent||null,i=!!(r&&s.some(a=>a&&a.id===r&&a.online));e.agents=t.agents,e._hasHandledAgentList=!0;let o=e.currentAgent||null;if(o){let a=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===o?e._yeaftAgentSeen:null,l=t.agents.find(c=>c.id===o)||null;e.currentView==="yeaft"&&eh(a,l)&&(e._yeaftReconnectCatchUpPending=!0),l?e._yeaftAgentSeen={id:o,online:!!l.online,version:l.version!=null?l.version:null}:a?a.online&&(e._yeaftAgentSeen={id:o,online:!1,version:a.version}):e._yeaftAgentSeen={id:o,online:!1,version:null}}{let a=new Set(t.agents.map(l=>l.id));for(let l of t.agents)e.proxyPorts[l.id]=l.proxyPorts||[],l.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(l.id,l.yeaftStatus);for(let l of Object.keys(e.proxyPorts))a.has(l)||delete e.proxyPorts[l]}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent);a&&(e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&!e.currentAgent){let a=t.agents.find(l=>l.online);a&&(e.currentAgent=a.id,e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let a=t.agents.filter(l=>l&&l.online&&l.id).map(l=>l.id);e.loadOpenedYeaftSessionsForConnectedAgents(a)}{let a=[],l=new Set;for(let d of t.agents)for(let u of d.conversations||[])l.has(u.id)||(l.add(u.id),a.push({...u,type:u.type,agentId:d.id,agentName:d.name}),u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title)));for(let d of a){d.agentOnline=!0;let u=e.conversations.find(f=>f.id===d.id);if(u)u.claudeSessionId=d.claudeSessionId||u.claudeSessionId,u.processing=d.processing,u.userId=d.userId,u.username=d.username,u.agentId=d.agentId,u.agentName=d.agentName,u.agentOnline=!0,d.type&&(u.type=d.type),d.name!==void 0&&(u.name=d.name);else{let f=e._recentlyDeletedSessions?.[d.id];if(f&&Date.now()-f<15e3)continue;e.conversations.push(d)}d.pinned&&!e.pinnedSessions.includes(d.id)&&e.pinnedSessions.push(d.id)}let c=new Set(t.agents.map(d=>d.id));e.conversations=e.conversations.filter(d=>{if(l.has(d.id)||e.activeConversations.includes(d.id))return!0;if(d.agentId&&c.has(d.agentId)){let u=e._recentlyDeletedSessions?.[d.id];return u&&Date.now()-u<15e3||(delete e.messagesMap[d.id],delete e.processingConversations[d.id],Ae(e,d.id),delete e.executionStatusMap[d.id]),!1}return d.agentId&&!c.has(d.agentId)&&(d.agentOnline=!1),!0});for(let d of a)if(d.processing&&!ns(e,d.id)&&!e._turnCompletedConvs?.has(d.id))e.processingConversations[d.id]=!0;else if(e.processingConversations[d.id]){delete e.processingConversations[d.id],Ae(e,d.id);let u=e.executionStatusMap[d.id];u&&(u.currentTool=null),e.finishStreamingForConversation(d.id)}for(let d of Object.keys(e.processingConversations))if(!l.has(d)){if(d.startsWith("yeaft-"))continue;delete e.processingConversations[d],Ae(e,d);let u=e.executionStatusMap[d];u&&(u.currentTool=null),e.finishStreamingForConversation(d)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let a=Date.now();for(let l of Object.keys(e._closedAt))a-e._closedAt[l]>3e4&&(delete e._closedAt[l],e._turnCompletedConvs?.delete(l))}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent&&l.online);if(a){let l=!!e._yeaftReconnectCatchUpPending,d=l||n&&!i;if(e.currentAgentInfo=a,d&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){e._yeaftReconnectCatchUpPending=!1;let u=l||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(u||l)&&e.requestYeaftSessionBootstrap({forceSessionReady:u,catchUpHistory:l})}if(!d)return;if(e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let f=e.messagesMap[e.currentConversation]||[],p=ss(f);p!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:p}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||qc(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){qc(e,{agentId:c.agentId,agentInfo:d});return}}}l&&(e.agents.find(d=>d.id===l&&d.online)?e.selectAgent(l):e.checkPendingRecovery())}}function Bc(e,t){let s=e.pendingAgentSelection||null;if(s){if(!(typeof t.requestId=="string"&&t.requestId?t.requestId===s.requestId:t.agentId===s.agentId))return!1;if(e.pendingAgentSelection=null,t.ok===!1)return e.agentSwitching=!1,!1}else{if(t.requestId)return!1;if(e.currentAgent&&t.agentId!==e.currentAgent)return!1}e.agentSwitching=!1;let n=e.currentAgent===t.agentId,r={id:t.agentId,name:t.agentName,workDir:t.workDir,capabilities:t.capabilities||["terminal","file_editor","background_tasks"],version:t.version||null};if(typeof e.activateYeaftAgent=="function"?e.activateYeaftAgent(t.agentId,r):(e.currentAgent=t.agentId,e.currentAgentInfo=r),Array.isArray(t.slashCommands)){let u=[...new Set(t.slashCommands)];e.slashCommandsMap[`agent:${t.agentId}`]=u}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});let i=t.conversations||[],o=new Set,a=i.filter(u=>o.has(u.id)?!1:(o.add(u.id),!0)).map(u=>({...u,agentId:t.agentId,agentName:t.agentName}));if(n&&e.currentConversation){let u=i.find(f=>f.id===e.currentConversation);u&&!a.find(f=>f.id===u.id)&&a.push({...u,agentId:t.agentId,agentName:t.agentName})}let l=new Set(a.map(u=>u.id)),c=e.conversations.filter(u=>!l.has(u.id));e.conversations=[...c,...a];for(let u of i)u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title));let d=new Set(i.map(u=>u.id));for(let u of i)if(u.processing&&!ns(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ae(e,u.id);let f=e.executionStatusMap[u.id];f&&(f.currentTool=null),e.finishStreamingForConversation(u.id)}for(let u of Object.keys(e.processingConversations))if(!d.has(u)){if(u.startsWith("yeaft-"))continue;if(!c.some(p=>p.id===u)){delete e.processingConversations[u],Ae(e,u);let p=e.executionStatusMap[u];p&&(p.currentTool=null),e.finishStreamingForConversation(u)}}if(e.currentView!=="yeaft"){if(n&&e.currentConversation){let u=e.conversations.find(f=>f.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,gt(e),e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation})}else{e.activeConversations=[],e.currentWorkDir=t.workDir;let u=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");u&&e.conversations.find(f=>f.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}Ll(e)}return!0}var Wc=F(()=>{Nt();ts();Ds()});function th(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Uc(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function ih(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 oh(e){let t=Uc(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Pn(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 jc(e){let t=Uc(),s=oh(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 ah(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,jc(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},rh))}function lh(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=_r(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=_r(n.rawRequest,t.rawRequestDelta)),n}function ch(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=lh(r,s.requestDelta);return t.set(n,o),{...s,systemPrompt:typeof s.systemPrompt=="string"&&s.systemPrompt?s.systemPrompt:o.systemPrompt,messages:Array.isArray(s.messages)&&s.messages.length>0?s.messages:o.messages,rawRequest:s.rawRequest??null,rawRequestBase:i}})}function zc(e,t){let s=_e();switch(e._lastPongAt=Date.now(),t.type){case"work_center_response":{let n=t.requestId?e.workCenterPending[t.requestId]:null;if(!n)break;clearTimeout(n.timer),delete e.workCenterPending[t.requestId],t.ok?n.resolve(t.data):n.reject(new Error(t.error||"Work Center request failed"));break}case"work_center_event":e.applyWorkCenterEvent(t.agentId,t.event);break;case"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=at(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,e.yeaftSessionHydrateSlices=[],e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,t.role&&(s.role=t.role),typeof e.requestYeaftSessionInventory=="function")e.requestYeaftSessionInventory();else{let n=e.conversations.map(r=>r.id).filter(Boolean);e.sendWsMessage({type:"get_agents",conversationIds:n.length>0?n:void 0})}e.checkPendingRecovery()}else e.addMessage({type:"error",content:t.error||Ee("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":Nc(e,t),e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"yeaft_session_hydrate":{if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionInventoryCompleteSupported!==!0&&!e.yeaftSessionHydrateRequestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;ih(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&ah(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?jc(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);break;case"session_ui_metadata_updated":{if(!e.finishSessionCatalogMutation?.(t)||t.ok!==!0)break;let n=e.sessionCatalog.find(r=>r.catalogKey===t.catalogKey);n&&(n.pinned=t.pinned===!0,n.sortRank=Number.isFinite(t.sortRank)?t.sortRank:null);break}case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Bc(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Cc(e,t);break;case"conversation_resumed":Ac(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":Rc(e,t);break;case"conversation_deleted":Do(e,t);break;case"conversation_delete_result":t.ok&&Do(e,t);break;case"turn_completed":xc(e,t);break;case"conversation_closed":Tc(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":Dc(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=_c(e,t);e.handleYeaftHistoryWindow(t,n);break}case"yeaft_tool_stats":{e._fetchYeaftToolStatsTimer&&(clearTimeout(e._fetchYeaftToolStatsTimer),e._fetchYeaftToolStatsTimer=null);let n=t?.snapshot,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};e.yeaftToolStats={snapshot:r,registered:Array.isArray(t?.registered)?t.registered:[],unused:Array.isArray(t?.unused)?t.unused:[],error:typeof t?.error=="string"?t.error:null,notice:typeof t?.notice=="string"?t.notice:null,fetchedAt:Date.now()},e.yeaftToolStatsLoading=!1;break}case"yeaft_debug_history":{let n=typeof t?.requestId=="string"?t.requestId:"",r=typeof t?.detailTurnId=="string"&&t.detailTurnId;if(n&&!r&&n!==e._yeaftDebugHistoryLatestListRequestId)break;e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let i=Array.isArray(t?.turns)?t.turns:[],o=t?.search?nh:sh,a=r?i:i.slice(-o),l=new Set(a.map(m=>m?.turnId).filter(Boolean)),c=ch(Array.isArray(t?.loops)?t.loops:[]),d=r?c:c.filter(m=>!m?.turnId||l.has(m.turnId)),u=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!r&&i.length>a.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(o,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let f=r?{...e.yeaftDebugTurnsById}:{};for(let m of a){let v=m?.turnId;if(!v)continue;let E=f[v];if(E){let V=m?.detailsLoaded?{...E,...m}:{...m,...E};V.memoryLoaded==null&&E.memoryLoaded!=null&&(V.memoryLoaded=E.memoryLoaded),V.memoryAdjust==null&&E.memoryAdjust!=null&&(V.memoryAdjust=E.memoryAdjust),f[v]=V}else f[v]=m}e.yeaftDebugTurnsById=f;let p=m=>m?.loopInstanceId||`${m?.turnId||""}#${m?.loopNumber||0}`,g=e.yeaftDebugLoops,b=new Map;for(let m of g)m&&b.set(p(m),m);let h=new Set,A=[];for(let m of d){if(!m)continue;let v=p(m);h.add(v),A.push(b.get(v)||m)}if(r)for(let m of g)!m||h.has(p(m))||A.push(m);e.yeaftDebugLoops=A;let w=new Set,S=[],y=m=>{!m||w.has(m)||(w.add(m),S.push(m))};if(r){for(let m of e.yeaftDebugTurnOrder)y(m);for(let m of a)y(m?.turnId)}else for(let m of a)y(m?.turnId);e.yeaftDebugTurnOrder=r?S:S.slice(-o);for(let m of u){if(!m)continue;let v=null,E=m.sessionId||m.groupId;typeof m.target=="string"&&m.target.includes("/")?v=m.target:typeof E=="string"&&E?v=`group/${E}`:v="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(v,m),m.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:m})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryFetchedAt=Date.now();break}case"chat_image":t.conversationId&&t.fileId&&e.addMessageToConversation(t.conversationId,{type:"chat-image",fileId:t.fileId,previewToken:t.previewToken,mimeType:t.mimeType});break;case"error":{let n=t.conversationId||e.currentConversation,r=["Permission denied","Agent not found","No conversation selected","Agent is still syncing","No agent available","Agent access denied"].some(c=>t.message?.includes(c));if((t.message?.includes("Agent is still syncing")||t.message?.includes("Agent not found"))&>(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n)),r&&n){let c=e.messagesMap[n];if(c&&c.length>0)for(let d=c.length-1;d>=0&&d>=c.length-5;d--){let u=c[d];if(u&&u.type==="error"&&u._sysErrBaseContent!==void 0){if(u._sysErrBaseContent===t.message&&Date.now()-(u._sysErrFirstAt||0)<=3e3){u._sysErrCount=(u._sysErrCount||1)+1,u.content=`${u._sysErrBaseContent} (\xD7${u._sysErrCount})`,u._sysErrRemoveTimer&&(clearTimeout(u._sysErrRemoveTimer),u._sysErrRemoveTimer=setTimeout(()=>{let f=e.messagesMap[n];if(f){let p=f.findIndex(g=>g.id===u.id);p>=0&&f.splice(p,1)}},5e3));return}break}}}let o=Date.now().toString()+Math.random().toString(36).substr(2,9),a={type:"error",content:t.message,transient:r,dbMessageId:r?"err_"+o:void 0};r&&(a._sysErrBaseContent=t.message,a._sysErrCount=1,a._sysErrFirstAt=Date.now()),e.addMessageToConversation(n,a);let l=null;if(r&&n){let c=e.messagesMap[n];c&&c.length>0&&(l=c[c.length-1])}if(r&&n&&l){let c=n,d="err_"+o;l._sysErrRemoveTimer=setTimeout(()=>{let u=e.messagesMap[c];if(u){let f=u.findIndex(p=>p.id===d);f>=0&&u.splice(f,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n));break}case"history_sessions_list":if(t.requestId&&e._historySessionsRequestId&&t.requestId!==e._historySessionsRequestId)break;e.historySessions=t.sessions||[],e.historySessionsLoading=!1;break;case"folders_list":if(t.requestId&&e._foldersRequestId&&t.requestId!==e._foldersRequestId)break;e.folders=t.folders||[],e.foldersLoading=!1,e._foldersResolve&&(e._foldersResolve(),e._foldersResolve=null);break;case"models_list":if(t.requestId&&e._modelsRequestId&&t.requestId!==e._modelsRequestId)break;e.providerModels=t.models||[],e.providerModelsLoading=!1,e._modelsTimeout&&(clearTimeout(e._modelsTimeout),e._modelsTimeout=null),e._modelsResolve&&(e._modelsResolve(e.providerModels),e._modelsResolve=null);break;case"conversation_refresh":Mc(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":Pc(e,t);break;case"slash_commands_update":if(Array.isArray(t.slashCommands)){let n=[...new Set(t.slashCommands)];if(t.commandSet==="yeaft"){let r=t.conversationId&&t.conversationId!=="__preload__"?t.conversationId:null,i=t.agentId&&e.yeaftConversationIdsByAgent?.[t.agentId]||null,o=r||i;o&&(e.slashCommandsMap[o]=n);let a=e.yeaftConversationId||null,l=t.agentId?e.currentAgent===t.agentId&&(i===a||r===a):r===a;a&&l&&(e.slashCommandsMap[a]=n)}else t.conversationId&&(e.slashCommandsMap[t.conversationId]=n),t.agentId&&(e.slashCommandsMap[`agent:${t.agentId}`]=n)}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});break;case"compact_status":{let n=t.conversationId;e.compactStatus={conversationId:n,status:t.status,message:t.message},t.status==="completed"?setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="completed"&&(e.compactStatus=null)},3e3):t.status==="compacting"&&setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="compacting"&&(e.compactStatus=null)},3e4)}break;case"pong_session":{let n=t.conversationId;if(!n)break;if(e._pongTimeouts?.[n]&&(clearTimeout(e._pongTimeouts[n]),delete e._pongTimeouts[n]),t.status==="unsupported"){Ae(e,n),gc(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n));else if(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[n]={status:t.status},t.status==="session-lost"||t.status==="cli-exited"){if(e._autoRefreshed||(e._autoRefreshed={}),!e._autoRefreshed[n]){e._autoRefreshed[n]=!0;let r=e.conversations.find(i=>i.id===n);e.sendWsMessage({type:"refresh_conversation",conversationId:n,agentId:r?.agentId})}delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n)}break}case"ask_user_question":if(t.conversationId){let n=()=>{let r=e.messagesMap[t.conversationId]||[];for(let i=r.length-1;i>=0;i--)if(r[i].type==="tool-use"&&r[i].toolName==="AskUserQuestion"&&!r[i].askRequestId)return r[i].askRequestId=t.requestId,r[i].askQuestions=t.questions,!0;return!1};if(!n()){let r=0,i=setInterval(()=>{r++,(n()||r>=10)&&clearInterval(i)},200)}}break;case"restart_agent_ack":window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId}}));break;case"upgrade_agent_ack":window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode}}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":case"file_saved":case"directory_listing":case"git_status_result":case"git_diff_result":case"git_op_result":case"file_op_result":case"file_search_result":t.type,t.type,window.dispatchEvent(new CustomEvent("workbench-message",{detail:t}));break;case"server_updating":e.connectionState="updating";break;case"context_usage":e.contextUsage={inputTokens:t.inputTokens,maxTokens:t.maxTokens,percentage:t.percentage,conversationId:t.conversationId};break;case"mcp_servers_list":case"mcp_config_updated":t.agentId&&t.servers&&(e.mcpServers[t.agentId]=t.servers);break;case"expert_roles_list":t.roles&&(e.expertRoleDefinitions=t.roles);break;case"llm_models_discovered":t.agentId&&(e.llmModelDiscovery=e.llmModelDiscovery||{},e.llmModelDiscovery[t.agentId]=t);break;case"llm_config":case"llm_config_updated":if(t.agentId){let n=t.agentConfig||th(t),r=t.effectiveConfig||n;e.llmConfig[t.agentId]={providers:t.providers||r.providers||[],primaryModel:t.primaryModel||r.primaryModel||null,fastModel:t.fastModel||r.fastModel||null,language:t.language||n.language||r.language||"en",needsSetup:t.needsSetup??r.needsSetup??!1,agentConfig:n,effectiveConfig:r,requestId:t.requestId||null,statusRefreshError:t.statusRefreshError||null,error:t.error||null,loaded:!0}}break;case"models_dev_registry":if(e.modelsDevRegistry={registry:t.registry||{},fetchedAt:t.fetchedAt||Date.now(),error:t.error||null,loaded:!0},e._modelsDevPending){let n=e._modelsDevPending;e._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(e.modelsDevRegistry)}break;case"yeaft_settings":case"yeaft_settings_updated":t.agentId&&(e.yeaftSettings[t.agentId]={maxConcurrentThreads:t.maxConcurrentThreads??6,autoArchiveIdleDays:t.autoArchiveIdleDays??30,error:t.error||null,loaded:!0,at:Date.now()});break;case"search_settings":case"search_settings_updated":{let n={backend:t.backend||"tavily",tavilyKeyConfigured:!!t.tavilyKeyConfigured,tavilyKeyMasked:t.tavilyKeyMasked||null,disableHtmlFallback:!!t.disableHtmlFallback,error:t.error||null,loaded:!0,at:Date.now()};e.searchSettings=n;let r=e._searchPending,i=t.type==="search_settings"?"load":"update";r&&r[i]&&(r[i](n),delete r[i]);break}case"tavily_usage":{let n=t.error?{error:t.error}:{plan:t.plan,used:t.used,limit:t.limit,paygoUsed:t.paygoUsed,paygoLimit:t.paygoLimit};e.tavilyUsage=n,e.tavilyUsageLoading=!1;let r=e._searchPending;r&&r.usage&&(r.usage(n),delete r.usage);break}case"yeaft_mcp_list_result":case"yeaft_mcp_add_result":case"yeaft_mcp_remove_result":case"yeaft_mcp_reload_result":case"yeaft_mcp_updated":{if(Array.isArray(t.servers)&&(e.yeaftMcpServers=t.servers),t.runtime&&typeof t.runtime=="object"&&(e.yeaftMcpRuntime={connected:!!t.runtime.connected,toolCount:t.runtime.toolCount||0,perServer:Array.isArray(t.runtime.perServer)?t.runtime.perServer:[]}),e.yeaftMcpLoading=!1,e.yeaftMcpError=t.error||null,t.requestId){let n=e._mcpPending;n&&n[t.requestId]&&(n[t.requestId](t),delete n[t.requestId])}break}case"conversation_mcp_update":t.conversationId&&t.servers&&(e.conversationMcpServers[t.conversationId]=t.servers),t.conversationId&&t.serverTools&&(e.conversationMcpServerTools[t.conversationId]=t.serverTools);break;case"btw_stream":e.appendBtwDelta(t.delta);break;case"btw_done":e.btwLoading=!1,t.btwSessionId&&(e.btwSessionId=t.btwSessionId);break;case"btw_error":{let n=e.btwMessages[e.btwMessages.length-1];n&&n.role==="assistant"&&(n.content="Error: "+t.error),e.btwLoading=!1;break}case"background_task_started":case"background_task_output":break;case"subagent_started":t.conversationId&&t.subagentId&&e.addSubagent(t.conversationId,{id:t.subagentId,slug:t.slug,type:t.subagentType,description:t.description,parentToolUseId:t.parentToolUseId});break;case"subagent_message":t.conversationId&&t.subagentId&&t.message&&e.appendSubagentMessage(t.conversationId,t.subagentId,t.message);break;case"subagent_completed":t.conversationId&&t.subagentId&&e.completeSubagent(t.conversationId,t.subagentId);break}}var sh,nh,rh,Kc=F(()=>{ct();gr();xt();Nt();ts();Vo();Rn();Wc();Rr();sh=1,nh=5,rh=500});function Gc(){return Object.values(Yc).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(ut).filter(s=>s.group===t.id)}))}function Qc(e){let t=[];for(let s of Object.values(ut)){t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName} ${s.title} ${s.titleEn}`.toLowerCase(),displayText:s.name,group:s.group});for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName} ${s.title} ${n.name} ${n.nameEn}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:s.group})}if(e&&e.length>0){for(let s of e)if(t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName||""} ${s.title} ${s.titleEn||""}`.toLowerCase(),displayText:s.name,group:"custom"}),s.actions)for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName||""} ${s.title} ${n.name} ${n.nameEn||""}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:"custom"})}return t}function is(e,t){let s=ut[e.role];if(s){if(e.action){let n=s.actions.find(r=>r.id===e.action);return n?`${s.name}\xB7${n.name}`:s.name}return s.name}if(t){let n=t.find(r=>r.id===e.role);if(n){if(e.action){let r=n.actions?.find(i=>i.id===e.action);return r?`${n.name}\xB7${r.name}`:n.name}return n.name}}return e.role}function Ho(e,t,s,n="zh-CN"){if(!e||e.length===0||!t||t.length===0)return null;let r=n==="zh-CN";if(!e.some(l=>!ut[l.role]&&t.some(c=>c.id===l.role)))return null;if(e.length===1){let{role:l,action:c}=e[0],d=t.find(f=>f.id===l);if(!d)return null;let u;if(c&&d.actions){let f=d.actions.find(p=>p.id===c);f?s?(u=(r?f.messageTemplate:f.messageTemplateEn)||"",u+=s):u=(r?f.defaultMessage:f.defaultMessageEn)||"":u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"")}else u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"");return{effectivePrompt:u}}let o=[];for(let{role:l,action:c}of e){let d=t.find(f=>f.id===l),u=ut[l];if(d)if(c){let f=d.actions?.find(p=>p.id===c);f&&o.push((r?f.messageTemplate:f.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
|
|
3
|
+
${u}`:u,f=!0;break}}if(!f){for(let p=l.length-1;p>=0;p--)if(l[p].type==="tool-use"&&!l[p].hasResult){l[p].hasResult=!0,l[p].toolResult=u;break}}}n.currentTool=null}else if(!r&&(typeof o=="string"&&o.trim()||Array.isArray(s.message?.attachments)&&s.message.attachments.length>0)){let l=s.message?.clientMessageId||s.clientMessageId||null,c={type:"user",content:o,clientMessageId:l},d=e.messagesMap[t]||[];if(d.some(f=>Ar(f,c))){if(l){for(let f=d.length-1;f>=0;f--)if(d[f].type==="user"&&d[f].clientMessageId===l){s.dbMessageId&&!d[f].dbMessageId&&(d[f].dbMessageId=s.dbMessageId),s.message?.id&&!d[f].messageId&&(d[f].id=s.message.id,d[f].messageId=s.message.id),s.ts&&!d[f].ts&&(d[f].ts=s.ts),Lc(e,d[f]);break}}}else{let f=e.addMessageToConversation(t,{...s.message?.id?{id:s.message.id,messageId:s.message.id}:{},...s.ts?{ts:s.ts}:{},type:"user",content:o,...s.message?.attachments?{attachments:s.message.attachments}:{},...s.message?.quote?{quote:s.message.quote}:{},...l?{clientMessageId:l}:{}});Lc(e,f)}}}else if(s.type==="result"){delete e.processingConversations[t],Ae(e,t);let r=e.conversations.find(c=>c.id===t);r&&r.connecting&&(r.connecting=!1);let i=e._currentYeaftSessionId||null;if(e._currentYeaftTurnId){let c=Object.entries(e.activeVpTurns||{}).find(([,d])=>(d?.turnId===e._currentYeaftTurnId||!d?.turnId&&d===e.activeVpTurns[e._currentYeaftTurnId])&&(!e._currentYeaftAgentId||!d?.agentId||d.agentId===e._currentYeaftAgentId));if(c){let[d,u]=c,{[d]:f,...p}=e.activeVpTurns;!i&&u?.sessionId&&(i=u.sessionId),e.activeVpTurns=p}}if(i&&e._currentYeaftVpId&&e.vpStatuses){let c=e._currentYeaftTurnId||null,d={...e.vpStatuses||{}},u=!1;for(let[f,p]of Object.entries(d))!p||p.vpId!==e._currentYeaftVpId||e._currentYeaftAgentId&&p.agentId&&p.agentId!==e._currentYeaftAgentId||(p.sessionId||p.groupId||null)!==i||c&&p.turnId&&p.turnId!==c||(d[f]={...p,state:"idle",turnId:null,since:Date.now()},u=!0);u&&(e.vpStatuses=d)}i&&typeof e.clearYeaftSessionProcessingIfIdle=="function"&&e.clearYeaftSessionProcessingIfIdle(i,{agentId:e._currentYeaftAgentId||null}),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now(),e._turnCompletedConvs||(e._turnCompletedConvs=new Set),e._turnCompletedConvs.add(t),n.currentTool=null,Bt(e,t);let o=e.messagesMap[t]||[],a=s.result_text||"";if(typeof a=="string"&&a.trim()){let c=!1;for(let d=o.length-1;d>=0;d--){if(o[d].type==="assistant"){c=!0;break}if(o[d].type==="user")break}c||e.appendToAssistantMessageForConversation(t,a.trim())}e.finishStreamingForConversation(t),!e.promoteCompletedYeaftHistoryOutline?.(t,e._currentYeaftTurnId||null)&&i&&e.invalidateYeaftHistoryOutline?.(i),e.sweepStaleStreamingForConversation(t)}}var Vc=F(()=>{Nt();Rr();Ao()});function is(e){if(e==null)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function _r(e,t){if(!t)return e??null;if(Object.prototype.hasOwnProperty.call(t,"base"))return is(t.base)??null;if(Object.prototype.hasOwnProperty.call(t,"replacement"))return is(t.replacement)??null;let s=e&&typeof e=="object"&&!Array.isArray(e)?is(e):{};if(t.set&&typeof t.set=="object")for(let[n,r]of Object.entries(t.set))s[n]=is(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]=is(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]=is(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(is(t.body.messagesAppend)||[])}s.body=n}return s}function Fc(e,t){return!t||!Object.prototype.hasOwnProperty.call(t,"rawRequestDelta")?e??null:_r(e??null,t.rawRequestDelta)}function Mn(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 Jm(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 Oc(e){let t=0,s=0;if(e&&Array.isArray(e.messages))for(let i of e.messages){let{messageText:o,toolText:a}=Jm(i);for(let l of o)t+=Mn(l);for(let l of a)s+=Mn(l)}let n=0,r=0;if(e&&typeof e.response=="string"&&(n+=Mn(e.response)),e&&Array.isArray(e.toolCalls)){for(let i of e.toolCalls)if(i&&(r+=Mn(String(i.name||"")),i.input!==void 0))try{r+=Mn(JSON.stringify(i.input))}catch{}}return{inputMessageTokens:t,inputToolTokens:s,outputMessageTokens:n,outputToolTokens:r,inputTotalEstimated:t+s,outputTotalEstimated:n+r}}function $o(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 Hc(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 Vo=F(()=>{});function dt(e,t){return!e||!t?"":`${e}${t}`}function Pn(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 Fo(e){return e?`${e}`:""}function Oo(e,t){return!e||!t?"":`${e}${t}`}var Rn=F(()=>{});function eh(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 qc(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 Nc(e,t){let s=Array.isArray(e.agents)?e.agents:[],n=e._hasHandledAgentList===!0,r=e.currentAgent||null,i=!!(r&&s.some(a=>a&&a.id===r&&a.online));e.agents=t.agents,e._hasHandledAgentList=!0;let o=e.currentAgent||null;if(o){let a=e._yeaftAgentSeen&&e._yeaftAgentSeen.id===o?e._yeaftAgentSeen:null,l=t.agents.find(c=>c.id===o)||null;e.currentView==="yeaft"&&eh(a,l)&&(e._yeaftReconnectCatchUpPending=!0),l?e._yeaftAgentSeen={id:o,online:!!l.online,version:l.version!=null?l.version:null}:a?a.online&&(e._yeaftAgentSeen={id:o,online:!1,version:a.version}):e._yeaftAgentSeen={id:o,online:!1,version:null}}{let a=new Set(t.agents.map(l=>l.id));for(let l of t.agents)e.proxyPorts[l.id]=l.proxyPorts||[],l.yeaftStatus&&typeof e.cacheYeaftAgentStatus=="function"&&e.cacheYeaftAgentStatus(l.id,l.yeaftStatus);for(let l of Object.keys(e.proxyPorts))a.has(l)||delete e.proxyPorts[l]}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent);a&&(e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&!e.currentAgent){let a=t.agents.find(l=>l.online);a&&(e.currentAgent=a.id,e.currentAgentInfo=a)}if(e.currentView==="yeaft"&&typeof e.loadOpenedYeaftSessionsForConnectedAgents=="function"){let a=t.agents.filter(l=>l&&l.online&&l.id).map(l=>l.id);e.loadOpenedYeaftSessionsForConnectedAgents(a)}{let a=[],l=new Set;for(let d of t.agents)for(let u of d.conversations||[])l.has(u.id)||(l.add(u.id),a.push({...u,type:u.type,agentId:d.id,agentName:d.name}),u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title)));for(let d of a){d.agentOnline=!0;let u=e.conversations.find(f=>f.id===d.id);if(u)u.claudeSessionId=d.claudeSessionId||u.claudeSessionId,u.processing=d.processing,u.userId=d.userId,u.username=d.username,u.agentId=d.agentId,u.agentName=d.agentName,u.agentOnline=!0,d.type&&(u.type=d.type),d.name!==void 0&&(u.name=d.name);else{let f=e._recentlyDeletedSessions?.[d.id];if(f&&Date.now()-f<15e3)continue;e.conversations.push(d)}d.pinned&&!e.pinnedSessions.includes(d.id)&&e.pinnedSessions.push(d.id)}let c=new Set(t.agents.map(d=>d.id));e.conversations=e.conversations.filter(d=>{if(l.has(d.id)||e.activeConversations.includes(d.id))return!0;if(d.agentId&&c.has(d.agentId)){let u=e._recentlyDeletedSessions?.[d.id];return u&&Date.now()-u<15e3||(delete e.messagesMap[d.id],delete e.processingConversations[d.id],Ae(e,d.id),delete e.executionStatusMap[d.id]),!1}return d.agentId&&!c.has(d.agentId)&&(d.agentOnline=!1),!0});for(let d of a)if(d.processing&&!rs(e,d.id)&&!e._turnCompletedConvs?.has(d.id))e.processingConversations[d.id]=!0;else if(e.processingConversations[d.id]){delete e.processingConversations[d.id],Ae(e,d.id);let u=e.executionStatusMap[d.id];u&&(u.currentTool=null),e.finishStreamingForConversation(d.id)}for(let d of Object.keys(e.processingConversations))if(!l.has(d)){if(d.startsWith("yeaft-"))continue;delete e.processingConversations[d],Ae(e,d);let u=e.executionStatusMap[d];u&&(u.currentTool=null),e.finishStreamingForConversation(d)}}if(localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions)),e._closedAt){let a=Date.now();for(let l of Object.keys(e._closedAt))a-e._closedAt[l]>3e4&&(delete e._closedAt[l],e._turnCompletedConvs?.delete(l))}if(e.currentAgent){let a=t.agents.find(l=>l.id===e.currentAgent&&l.online);if(a){let l=!!e._yeaftReconnectCatchUpPending,d=l||n&&!i;if(e.currentAgentInfo=a,d&&(e._offlineConversationRestoreKey=null,e.sendWsMessage({type:"select_agent",agentId:e.currentAgent,silent:!0})),e.currentView==="yeaft"&&typeof e.requestYeaftSessionBootstrap=="function"){e._yeaftReconnectCatchUpPending=!1;let u=l||!e.yeaftSessionReady||!e.yeaftModel||!e.yeaftStatus;(u||l)&&e.requestYeaftSessionBootstrap({forceSessionReady:u,catchUpHistory:l})}if(!d)return;if(e.currentConversation){let u=e.conversations.find(g=>g.id===e.currentConversation);e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation});let f=e.messagesMap[e.currentConversation]||[],p=ns(f);p!=null?e.requestChatHistory?.(e.currentConversation,{mode:"delta",afterMessageId:p}):e.requestChatHistory?.(e.currentConversation,{mode:"recent",turns:5}),e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}else e.recoveryDismissed||qc(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){qc(e,{agentId:c.agentId,agentInfo:d});return}}}l&&(e.agents.find(d=>d.id===l&&d.online)?e.selectAgent(l):e.checkPendingRecovery())}}function Bc(e,t){let s=e.pendingAgentSelection||null;if(s){if(!(typeof t.requestId=="string"&&t.requestId?t.requestId===s.requestId:t.agentId===s.agentId))return!1;if(e.pendingAgentSelection=null,t.ok===!1)return e.agentSwitching=!1,!1}else{if(t.requestId)return!1;if(e.currentAgent&&t.agentId!==e.currentAgent)return!1}e.agentSwitching=!1;let n=e.currentAgent===t.agentId,r={id:t.agentId,name:t.agentName,workDir:t.workDir,capabilities:t.capabilities||["terminal","file_editor","background_tasks"],version:t.version||null};if(typeof e.activateYeaftAgent=="function"?e.activateYeaftAgent(t.agentId,r):(e.currentAgent=t.agentId,e.currentAgentInfo=r),Array.isArray(t.slashCommands)){let u=[...new Set(t.slashCommands)];e.slashCommandsMap[`agent:${t.agentId}`]=u}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});let i=t.conversations||[],o=new Set,a=i.filter(u=>o.has(u.id)?!1:(o.add(u.id),!0)).map(u=>({...u,agentId:t.agentId,agentName:t.agentName}));if(n&&e.currentConversation){let u=i.find(f=>f.id===e.currentConversation);u&&!a.find(f=>f.id===u.id)&&a.push({...u,agentId:t.agentId,agentName:t.agentName})}let l=new Set(a.map(u=>u.id)),c=e.conversations.filter(u=>!l.has(u.id));e.conversations=[...c,...a];for(let u of i)u.title&&(u.customTitle&&(e.customConversationTitles[u.id]=u.title),e.conversationTitles[u.id]||(e.conversationTitles[u.id]=u.title));let d=new Set(i.map(u=>u.id));for(let u of i)if(u.processing&&!rs(e,u.id)&&!e._turnCompletedConvs?.has(u.id))e.processingConversations[u.id]=!0;else if(e.processingConversations[u.id]){delete e.processingConversations[u.id],Ae(e,u.id);let f=e.executionStatusMap[u.id];f&&(f.currentTool=null),e.finishStreamingForConversation(u.id)}for(let u of Object.keys(e.processingConversations))if(!d.has(u)){if(u.startsWith("yeaft-"))continue;if(!c.some(p=>p.id===u)){delete e.processingConversations[u],Ae(e,u);let p=e.executionStatusMap[u];p&&(p.currentTool=null),e.finishStreamingForConversation(u)}}if(e.currentView!=="yeaft"){if(n&&e.currentConversation){let u=e.conversations.find(f=>f.id===e.currentConversation);e.currentWorkDir=u?.workDir||e.currentWorkDir||t.workDir,gt(e),e.sendWsMessage({type:"select_conversation",conversationId:e.currentConversation})}else{e.activeConversations=[],e.currentWorkDir=t.workDir;let u=e.lastViewedConversation||localStorage.getItem("lastViewedConversation");u&&e.conversations.find(f=>f.id===u)&&(e.autoRestoreConversation(u),e.pendingRecovery=null)}Ll(e)}return!0}var Wc=F(()=>{Nt();ss();Ds()});function th(e={}){return{providers:e.providers||[],primaryModel:e.primaryModel||null,fastModel:e.fastModel||null,language:e.language||"en"}}function Uc(){return window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()}function ih(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 oh(e){let t=Uc(),s=null;try{s=localStorage.getItem("lastViewedYeaftSession")||null}catch{}let n=Pn(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 jc(e){let t=Uc(),s=oh(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 ah(e){let t=e.yeaftSessionHydrateRequestId||null;e.yeaftSessionInventoryCompleteSupported!==!1||!t||(clearTimeout(e._legacyYeaftSessionHydrateTimer),e._legacyYeaftSessionHydrateTimer=setTimeout(()=>{e.yeaftSessionHydrateRequestId===t&&(e._legacyYeaftSessionHydrateTimer=null,jc(e),e._hasHandledYeaftSessionHydrate=!0,e.yeaftSessionHydrateRequestId=null,e.yeaftSessionHydrateError=null,e._yeaftSessionInventorySocketQuarantined=!0)},rh))}function lh(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=_r(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=_r(n.rawRequest,t.rawRequestDelta)),n}function ch(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=lh(r,s.requestDelta);return t.set(n,o),{...s,systemPrompt:typeof s.systemPrompt=="string"&&s.systemPrompt?s.systemPrompt:o.systemPrompt,messages:Array.isArray(s.messages)&&s.messages.length>0?s.messages:o.messages,rawRequest:s.rawRequest??null,rawRequestBase:i}})}function zc(e,t){let s=_e();switch(e._lastPongAt=Date.now(),t.type){case"work_center_response":{let n=t.requestId?e.workCenterPending[t.requestId]:null;if(!n)break;clearTimeout(n.timer),delete e.workCenterPending[t.requestId],t.ok?n.resolve(t.data):n.reject(new Error(t.error||"Work Center request failed"));break}case"work_center_event":e.applyWorkCenterEvent(t.agentId,t.event);break;case"auth_result":if(t.success){if(e.authenticated=!0,t.sessionKey&&(e.sessionKey=at(t.sessionKey),s.setSessionKey(t.sessionKey)),t.acceptPlaintext===!0&&(e.serverEncryptionRequired=!1),e.yeaftSessionInventoryCompleteSupported=t.yeaftSessionInventoryComplete===!0,e.yeaftSessionHydrateSlices=[],e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,t.role&&(s.role=t.role),typeof e.requestYeaftSessionInventory=="function")e.requestYeaftSessionInventory();else{let n=e.conversations.map(r=>r.id).filter(Boolean);e.sendWsMessage({type:"get_agents",conversationIds:n.length>0?n:void 0})}e.checkPendingRecovery()}else e.addMessage({type:"error",content:t.error||Ee("login.error.loginFailed")}),s.handleAuthFailure?.(void 0,t._wsAuthToken,t._wsAuthGeneration);break;case"agent_list":Nc(e,t),e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"yeaft_session_hydrate":{if(e.yeaftSessionInventoryCompleteSupported===!0&&(!t.requestId||t.requestId!==e.yeaftSessionHydrateRequestId)||e.yeaftSessionInventoryCompleteSupported!==!0&&!e.yeaftSessionHydrateRequestId||t.requestId&&e.yeaftSessionHydrateRequestId&&t.requestId!==e.yeaftSessionHydrateRequestId)break;ih(e,t),e.yeaftSessionInventoryCompleteSupported!==!0&&ah(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?jc(e):e.yeaftSessionHydrateSlices=[],e.yeaftSessionHydrateRequestId=null,e._hasHandledYeaftSessionHydrate=t.ok!==!1,e.yeaftSessionHydrateError=t.ok===!1?t.error||"session_inventory_failed":null;break;case"session_catalog_snapshot":e.applySessionCatalogSnapshot(t.catalog,t.projectsAuthoritative===!0?t.projects:null);break;case"session_ui_metadata_updated":{if(!e.finishSessionCatalogMutation?.(t)||t.ok!==!0)break;let n=e.sessionCatalog.find(r=>r.catalogKey===t.catalogKey);n&&(n.pinned=t.pinned===!0,n.sortRank=Number.isFinite(t.sortRank)?t.sortRank:null);break}case"session_catalog_reorder_result":e.finishSessionCatalogMutation?.(t);break;case"agent_selected":if(!Bc(e,t))break;e.workCenterOpen&&e.workCenterAgentId&&e.listWorkItems(e.workCenterAgentId).catch(()=>{});break;case"conversation_created":Cc(e,t);break;case"conversation_resumed":Ac(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":Rc(e,t);break;case"conversation_deleted":Do(e,t);break;case"conversation_delete_result":t.ok&&Do(e,t);break;case"turn_completed":xc(e,t);break;case"conversation_closed":Tc(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":Dc(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=_c(e,t);e.handleYeaftHistoryWindow(t,n);break}case"yeaft_tool_stats":{e._fetchYeaftToolStatsTimer&&(clearTimeout(e._fetchYeaftToolStatsTimer),e._fetchYeaftToolStatsTimer=null);let n=t?.snapshot,r=n&&typeof n=="object"&&!Array.isArray(n)?n:{};e.yeaftToolStats={snapshot:r,registered:Array.isArray(t?.registered)?t.registered:[],unused:Array.isArray(t?.unused)?t.unused:[],error:typeof t?.error=="string"?t.error:null,notice:typeof t?.notice=="string"?t.notice:null,fetchedAt:Date.now()},e.yeaftToolStatsLoading=!1;break}case"yeaft_debug_history":{let n=typeof t?.requestId=="string"?t.requestId:"",r=typeof t?.detailTurnId=="string"&&t.detailTurnId;if(n&&!r&&n!==e._yeaftDebugHistoryLatestListRequestId)break;e._fetchYeaftDebugHistoryTimer&&(clearTimeout(e._fetchYeaftDebugHistoryTimer),e._fetchYeaftDebugHistoryTimer=null),e._yeaftDebugHistoryInFlightKey=null;let i=Array.isArray(t?.turns)?t.turns:[],o=t?.search?nh:sh,a=r?i:i.slice(-o),l=new Set(a.map(m=>m?.turnId).filter(Boolean)),c=ch(Array.isArray(t?.loops)?t.loops:[]),d=r?c:c.filter(m=>!m?.turnId||l.has(m.turnId)),u=Array.isArray(t?.dreamEvents)?t.dreamEvents:[];e.yeaftDebugHistoryHasMore=!!t?.hasMore||!r&&i.length>a.length,!t?.detailTurnId&&Number.isFinite(t?.limit)&&t.limit>0&&(e.yeaftDebugHistoryLimit=Math.min(o,t.limit)),(!e.yeaftDebugTurnsById||typeof e.yeaftDebugTurnsById!="object")&&(e.yeaftDebugTurnsById={}),Array.isArray(e.yeaftDebugLoops)||(e.yeaftDebugLoops=[]),Array.isArray(e.yeaftDebugTurnOrder)||(e.yeaftDebugTurnOrder=[]);let f=r?{...e.yeaftDebugTurnsById}:{};for(let m of a){let v=m?.turnId;if(!v)continue;let E=f[v];if(E){let V=m?.detailsLoaded?{...E,...m}:{...m,...E};V.memoryLoaded==null&&E.memoryLoaded!=null&&(V.memoryLoaded=E.memoryLoaded),V.memoryAdjust==null&&E.memoryAdjust!=null&&(V.memoryAdjust=E.memoryAdjust),f[v]=V}else f[v]=m}e.yeaftDebugTurnsById=f;let p=m=>m?.loopInstanceId||`${m?.turnId||""}#${m?.loopNumber||0}`,g=e.yeaftDebugLoops,b=new Map;for(let m of g)m&&b.set(p(m),m);let h=new Set,A=[];for(let m of d){if(!m)continue;let v=p(m);h.add(v),A.push(b.get(v)||m)}if(r)for(let m of g)!m||h.has(p(m))||A.push(m);e.yeaftDebugLoops=A;let w=new Set,S=[],y=m=>{!m||w.has(m)||(w.add(m),S.push(m))};if(r){for(let m of e.yeaftDebugTurnOrder)y(m);for(let m of a)y(m?.turnId)}else for(let m of a)y(m?.turnId);e.yeaftDebugTurnOrder=r?S:S.slice(-o);for(let m of u){if(!m)continue;let v=null,E=m.sessionId||m.groupId;typeof m.target=="string"&&m.target.includes("/")?v=m.target:typeof E=="string"&&E?v=`group/${E}`:v="*",typeof e._appendDreamEvent=="function"&&e._appendDreamEvent(v,m),m.type==="dream_progress"&&typeof e.handleYeaftOutput=="function"&&e.handleYeaftOutput({event:m})}e.yeaftDebugHistoryLoading=!1,e.yeaftDebugHistoryError=typeof t?.error=="string"?t.error:null,e.yeaftDebugHistoryFetchedAt=Date.now();break}case"chat_image":t.conversationId&&t.fileId&&e.addMessageToConversation(t.conversationId,{type:"chat-image",fileId:t.fileId,previewToken:t.previewToken,mimeType:t.mimeType});break;case"error":{let n=t.conversationId||e.currentConversation,r=["Permission denied","Agent not found","No conversation selected","Agent is still syncing","No agent available","Agent access denied"].some(c=>t.message?.includes(c));if((t.message?.includes("Agent is still syncing")||t.message?.includes("Agent not found"))&>(e),["No conversation selected","Agent is still syncing","No agent available"].some(c=>t.message?.includes(c))&&n&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n)),r&&n){let c=e.messagesMap[n];if(c&&c.length>0)for(let d=c.length-1;d>=0&&d>=c.length-5;d--){let u=c[d];if(u&&u.type==="error"&&u._sysErrBaseContent!==void 0){if(u._sysErrBaseContent===t.message&&Date.now()-(u._sysErrFirstAt||0)<=3e3){u._sysErrCount=(u._sysErrCount||1)+1,u.content=`${u._sysErrBaseContent} (\xD7${u._sysErrCount})`,u._sysErrRemoveTimer&&(clearTimeout(u._sysErrRemoveTimer),u._sysErrRemoveTimer=setTimeout(()=>{let f=e.messagesMap[n];if(f){let p=f.findIndex(g=>g.id===u.id);p>=0&&f.splice(p,1)}},5e3));return}break}}}let o=Date.now().toString()+Math.random().toString(36).substr(2,9),a={type:"error",content:t.message,transient:r,dbMessageId:r?"err_"+o:void 0};r&&(a._sysErrBaseContent=t.message,a._sysErrCount=1,a._sysErrFirstAt=Date.now()),e.addMessageToConversation(n,a);let l=null;if(r&&n){let c=e.messagesMap[n];c&&c.length>0&&(l=c[c.length-1])}if(r&&n&&l){let c=n,d="err_"+o;l._sysErrRemoveTimer=setTimeout(()=>{let u=e.messagesMap[c];if(u){let f=u.findIndex(p=>p.id===d);f>=0&&u.splice(f,1)}},5e3)}!r&&n&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n));break}case"history_sessions_list":if(t.requestId&&e._historySessionsRequestId&&t.requestId!==e._historySessionsRequestId)break;e.historySessions=t.sessions||[],e.historySessionsLoading=!1;break;case"folders_list":if(t.requestId&&e._foldersRequestId&&t.requestId!==e._foldersRequestId)break;e.folders=t.folders||[],e.foldersLoading=!1,e._foldersResolve&&(e._foldersResolve(),e._foldersResolve=null);break;case"models_list":if(t.requestId&&e._modelsRequestId&&t.requestId!==e._modelsRequestId)break;e.providerModels=t.models||[],e.providerModelsLoading=!1,e._modelsTimeout&&(clearTimeout(e._modelsTimeout),e._modelsTimeout=null),e._modelsResolve&&(e._modelsResolve(e.providerModels),e._modelsResolve=null);break;case"conversation_refresh":Mc(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":Pc(e,t);break;case"slash_commands_update":if(Array.isArray(t.slashCommands)){let n=[...new Set(t.slashCommands)];if(t.commandSet==="yeaft"){let r=t.conversationId&&t.conversationId!=="__preload__"?t.conversationId:null,i=t.agentId&&e.yeaftConversationIdsByAgent?.[t.agentId]||null,o=r||i;o&&(e.slashCommandsMap[o]=n);let a=e.yeaftConversationId||null,l=t.agentId?e.currentAgent===t.agentId&&(i===a||r===a):r===a;a&&l&&(e.slashCommandsMap[a]=n)}else t.conversationId&&(e.slashCommandsMap[t.conversationId]=n),t.agentId&&(e.slashCommandsMap[`agent:${t.agentId}`]=n)}t.slashCommandDescriptions&&(e.slashCommandDescriptions={...e.slashCommandDescriptions,...t.slashCommandDescriptions});break;case"compact_status":{let n=t.conversationId;e.compactStatus={conversationId:n,status:t.status,message:t.message},t.status==="completed"?setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="completed"&&(e.compactStatus=null)},3e3):t.status==="compacting"&&setTimeout(()=>{e.compactStatus?.conversationId===n&&e.compactStatus?.status==="compacting"&&(e.compactStatus=null)},3e4)}break;case"pong_session":{let n=t.conversationId;if(!n)break;if(e._pongTimeouts?.[n]&&(clearTimeout(e._pongTimeouts[n]),delete e._pongTimeouts[n]),t.status==="unsupported"){Ae(e,n),gc(e,n);break}if(t.status==="ok")e.sessionHealth?.[n]&&delete e.sessionHealth[n],!t.isProcessing&&e.processingConversations[n]&&(delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n));else if(e.sessionHealth||(e.sessionHealth={}),e.sessionHealth[n]={status:t.status},t.status==="session-lost"||t.status==="cli-exited"){if(e._autoRefreshed||(e._autoRefreshed={}),!e._autoRefreshed[n]){e._autoRefreshed[n]=!0;let r=e.conversations.find(i=>i.id===n);e.sendWsMessage({type:"refresh_conversation",conversationId:n,agentId:r?.agentId})}delete e.processingConversations[n],Ae(e,n),e.finishStreamingForConversation(n)}break}case"ask_user_question":if(t.conversationId){let n=()=>{let r=e.messagesMap[t.conversationId]||[];for(let i=r.length-1;i>=0;i--)if(r[i].type==="tool-use"&&r[i].toolName==="AskUserQuestion"&&!r[i].askRequestId)return r[i].askRequestId=t.requestId,r[i].askQuestions=t.questions,!0;return!1};if(!n()){let r=0,i=setInterval(()=>{r++,(n()||r>=10)&&clearInterval(i)},200)}}break;case"restart_agent_ack":window.dispatchEvent(new CustomEvent("agent-restart-ack",{detail:{agentId:t.agentId}}));break;case"upgrade_agent_ack":window.dispatchEvent(new CustomEvent("agent-upgrade-ack",{detail:{agentId:t.agentId,success:t.success,error:t.error,alreadyLatest:t.alreadyLatest,version:t.version,reason:t.reason,currentNode:t.currentNode,requiredNode:t.requiredNode}}));break;case"terminal_created":case"terminal_output":case"terminal_closed":case"terminal_error":case"file_content":case"file_saved":case"directory_listing":case"git_status_result":case"git_diff_result":case"git_op_result":case"file_op_result":case"file_search_result":t.type,t.type,window.dispatchEvent(new CustomEvent("workbench-message",{detail:t}));break;case"server_updating":e.connectionState="updating";break;case"context_usage":e.contextUsage={inputTokens:t.inputTokens,maxTokens:t.maxTokens,percentage:t.percentage,conversationId:t.conversationId};break;case"mcp_servers_list":case"mcp_config_updated":t.agentId&&t.servers&&(e.mcpServers[t.agentId]=t.servers);break;case"expert_roles_list":t.roles&&(e.expertRoleDefinitions=t.roles);break;case"llm_models_discovered":t.agentId&&(e.llmModelDiscovery=e.llmModelDiscovery||{},e.llmModelDiscovery[t.agentId]=t);break;case"llm_config":case"llm_config_updated":if(t.agentId){let n=t.agentConfig||th(t),r=t.effectiveConfig||n;e.llmConfig[t.agentId]={providers:t.providers||r.providers||[],primaryModel:t.primaryModel||r.primaryModel||null,fastModel:t.fastModel||r.fastModel||null,language:t.language||n.language||r.language||"en",needsSetup:t.needsSetup??r.needsSetup??!1,agentConfig:n,effectiveConfig:r,requestId:t.requestId||null,statusRefreshError:t.statusRefreshError||null,error:t.error||null,loaded:!0}}break;case"models_dev_registry":if(e.modelsDevRegistry={registry:t.registry||{},fetchedAt:t.fetchedAt||Date.now(),error:t.error||null,loaded:!0},e._modelsDevPending){let n=e._modelsDevPending;e._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(e.modelsDevRegistry)}break;case"yeaft_settings":case"yeaft_settings_updated":t.agentId&&(e.yeaftSettings[t.agentId]={maxConcurrentThreads:t.maxConcurrentThreads??6,autoArchiveIdleDays:t.autoArchiveIdleDays??30,error:t.error||null,loaded:!0,at:Date.now()});break;case"search_settings":case"search_settings_updated":{let n={backend:t.backend||"tavily",tavilyKeyConfigured:!!t.tavilyKeyConfigured,tavilyKeyMasked:t.tavilyKeyMasked||null,disableHtmlFallback:!!t.disableHtmlFallback,error:t.error||null,loaded:!0,at:Date.now()};e.searchSettings=n;let r=e._searchPending,i=t.type==="search_settings"?"load":"update";r&&r[i]&&(r[i](n),delete r[i]);break}case"tavily_usage":{let n=t.error?{error:t.error}:{plan:t.plan,used:t.used,limit:t.limit,paygoUsed:t.paygoUsed,paygoLimit:t.paygoLimit};e.tavilyUsage=n,e.tavilyUsageLoading=!1;let r=e._searchPending;r&&r.usage&&(r.usage(n),delete r.usage);break}case"yeaft_mcp_list_result":case"yeaft_mcp_add_result":case"yeaft_mcp_remove_result":case"yeaft_mcp_reload_result":case"yeaft_mcp_updated":{if(Array.isArray(t.servers)&&(e.yeaftMcpServers=t.servers),t.runtime&&typeof t.runtime=="object"&&(e.yeaftMcpRuntime={connected:!!t.runtime.connected,toolCount:t.runtime.toolCount||0,perServer:Array.isArray(t.runtime.perServer)?t.runtime.perServer:[]}),e.yeaftMcpLoading=!1,e.yeaftMcpError=t.error||null,t.requestId){let n=e._mcpPending;n&&n[t.requestId]&&(n[t.requestId](t),delete n[t.requestId])}break}case"conversation_mcp_update":t.conversationId&&t.servers&&(e.conversationMcpServers[t.conversationId]=t.servers),t.conversationId&&t.serverTools&&(e.conversationMcpServerTools[t.conversationId]=t.serverTools);break;case"btw_stream":e.appendBtwDelta(t.delta);break;case"btw_done":e.btwLoading=!1,t.btwSessionId&&(e.btwSessionId=t.btwSessionId);break;case"btw_error":{let n=e.btwMessages[e.btwMessages.length-1];n&&n.role==="assistant"&&(n.content="Error: "+t.error),e.btwLoading=!1;break}case"background_task_started":case"background_task_output":break;case"subagent_started":t.conversationId&&t.subagentId&&e.addSubagent(t.conversationId,{id:t.subagentId,slug:t.slug,type:t.subagentType,description:t.description,parentToolUseId:t.parentToolUseId});break;case"subagent_message":t.conversationId&&t.subagentId&&t.message&&e.appendSubagentMessage(t.conversationId,t.subagentId,t.message);break;case"subagent_completed":t.conversationId&&t.subagentId&&e.completeSubagent(t.conversationId,t.subagentId);break}}var sh,nh,rh,Kc=F(()=>{ct();gr();xt();Nt();ss();Vo();Rn();Wc();Rr();sh=1,nh=5,rh=500});function Gc(){return Object.values(Yc).sort((t,s)=>t.order-s.order).map(t=>({teamId:t.id,team:t,roles:Object.values(ut).filter(s=>s.group===t.id)}))}function Qc(e){let t=[];for(let s of Object.values(ut)){t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName} ${s.title} ${s.titleEn}`.toLowerCase(),displayText:s.name,group:s.group});for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName} ${s.title} ${n.name} ${n.nameEn}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:s.group})}if(e&&e.length>0){for(let s of e)if(t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:null,actionName:null,searchText:`${s.name} ${s.fullName||""} ${s.title} ${s.titleEn||""}`.toLowerCase(),displayText:s.name,group:"custom"}),s.actions)for(let n of s.actions)t.push({roleId:s.id,roleName:s.name,roleTitle:s.title,actionId:n.id,actionName:n.name,searchText:`${s.name} ${s.fullName||""} ${s.title} ${n.name} ${n.nameEn||""}`.toLowerCase(),displayText:`${s.name}\xB7${n.name}`,group:"custom"})}return t}function os(e,t){let s=ut[e.role];if(s){if(e.action){let n=s.actions.find(r=>r.id===e.action);return n?`${s.name}\xB7${n.name}`:s.name}return s.name}if(t){let n=t.find(r=>r.id===e.role);if(n){if(e.action){let r=n.actions?.find(i=>i.id===e.action);return r?`${n.name}\xB7${r.name}`:n.name}return n.name}}return e.role}function Ho(e,t,s,n="zh-CN"){if(!e||e.length===0||!t||t.length===0)return null;let r=n==="zh-CN";if(!e.some(l=>!ut[l.role]&&t.some(c=>c.id===l.role)))return null;if(e.length===1){let{role:l,action:c}=e[0],d=t.find(f=>f.id===l);if(!d)return null;let u;if(c&&d.actions){let f=d.actions.find(p=>p.id===c);f?s?(u=(r?f.messageTemplate:f.messageTemplateEn)||"",u+=s):u=(r?f.defaultMessage:f.defaultMessageEn)||"":u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"")}else u=((r?d.messagePrefix:d.messagePrefixEn)||"")+(s||"");return{effectivePrompt:u}}let o=[];for(let{role:l,action:c}of e){let d=t.find(f=>f.id===l),u=ut[l];if(d)if(c){let f=d.actions?.find(p=>p.id===c);f&&o.push((r?f.messageTemplate:f.messageTemplateEn)||"")}else o.push((r?d.messagePrefix:d.messagePrefixEn)||"");else if(u)return null}return o.length===0?null:{effectivePrompt:o.join(`
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
`)+(s||"")}}function Zc(e){return Object.values(Yc).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var Yc,ut,Xc,os,_n=F(()=>{Yc={dev:{id:"dev",name:"\u8F6F\u4EF6\u5F00\u53D1",nameEn:"Software Dev",icon:"\u{1F5A5}\uFE0F",order:0},trading:{id:"trading",name:"\u4EA4\u6613",nameEn:"Trading",icon:"\u{1F4C8}",order:1,adminOnly:!0},writing:{id:"writing",name:"\u5199\u4F5C",nameEn:"Writing",icon:"\u270D\uFE0F",order:2,adminOnly:!0},video:{id:"video",name:"\u89C6\u9891",nameEn:"Video",icon:"\u{1F3AC}",order:3,adminOnly:!0}},ut={jobs:{id:"jobs",name:"Jobs",fullName:"Steve Jobs",title:"\u4EA7\u54C1\u7ECF\u7406",titleEn:"Product Manager",group:"dev",actions:[{id:"product-analysis",name:"\u4EA7\u54C1\u5206\u6790",nameEn:"Product Analysis"},{id:"design-review",name:"\u8BBE\u8BA1\u5BA1\u67E5",nameEn:"Design Review"},{id:"requirements",name:"\u9700\u6C42\u62C6\u89E3",nameEn:"Requirements"}]},fowler:{id:"fowler",name:"Fowler",fullName:"Martin Fowler",title:"\u8F6F\u4EF6\u67B6\u6784\u5E08",titleEn:"Software Architect",group:"dev",actions:[{id:"architecture",name:"\u67B6\u6784\u5BA1\u67E5",nameEn:"Architecture Review"},{id:"refactoring",name:"\u91CD\u6784\u5206\u6790",nameEn:"Refactoring"},{id:"code-review",name:"\u4EE3\u7801\u5BA1\u67E5",nameEn:"Code Review"}]},torvalds:{id:"torvalds",name:"Torvalds",fullName:"Linus Torvalds",title:"\u7CFB\u7EDF\u5F00\u53D1\u5DE5\u7A0B\u5E08",titleEn:"Systems Engineer",group:"dev",actions:[{id:"system-design",name:"\u7CFB\u7EDF\u8BBE\u8BA1",nameEn:"System Design"},{id:"performance",name:"\u6027\u80FD\u4F18\u5316",nameEn:"Performance"},{id:"code-style",name:"\u4EE3\u7801\u98CE\u683C",nameEn:"Code Style"},{id:"implementation",name:"\u4EE3\u7801\u5B9E\u73B0",nameEn:"Implementation"}]},beck:{id:"beck",name:"Beck",fullName:"Kent Beck",title:"\u6D4B\u8BD5\u5DE5\u7A0B\u5E08",titleEn:"Test Engineer",group:"dev",actions:[{id:"test-strategy",name:"\u6D4B\u8BD5\u7B56\u7565",nameEn:"Test Strategy"},{id:"tdd-guide",name:"TDD \u6307\u5BFC",nameEn:"TDD Guide"},{id:"quality-check",name:"\u8D28\u91CF\u8BC4\u4F30",nameEn:"Quality Check"}]},schneier:{id:"schneier",name:"Schneier",fullName:"Bruce Schneier",title:"\u5B89\u5168\u5DE5\u7A0B\u5E08",titleEn:"Security Engineer",group:"dev",actions:[{id:"security-audit",name:"\u5B89\u5168\u5BA1\u8BA1",nameEn:"Security Audit"},{id:"threat-model",name:"\u5A01\u80C1\u5EFA\u6A21",nameEn:"Threat Model"},{id:"auth-review",name:"\u8BA4\u8BC1\u5BA1\u67E5",nameEn:"Auth Review"}]},rams:{id:"rams",name:"Rams",fullName:"Dieter Rams",title:"UI/UX \u8BBE\u8BA1\u5E08",titleEn:"UI/UX Designer",group:"dev",actions:[{id:"ui-review",name:"\u754C\u9762\u5BA1\u67E5",nameEn:"UI Review"},{id:"interaction",name:"\u4EA4\u4E92\u8BBE\u8BA1",nameEn:"Interaction Design"},{id:"layout",name:"\u5E03\u5C40\u4F18\u5316",nameEn:"Layout Optimization"}]},graham:{id:"graham",name:"Graham",fullName:"Paul Graham",title:"\u6280\u672F\u5199\u4F5C / \u65B9\u6848\u8BC4\u4F30\u5E08",titleEn:"Tech Writer / Evaluator",group:"dev",actions:[{id:"writing",name:"\u6280\u672F\u5199\u4F5C",nameEn:"Tech Writing"},{id:"proposal-review",name:"\u65B9\u6848\u8BC4\u4F30",nameEn:"Proposal Review"},{id:"explain",name:"\u6982\u5FF5\u89E3\u91CA",nameEn:"Explain"}]},hightower:{id:"hightower",name:"Hightower",fullName:"Kelsey Hightower",title:"DevOps / \u8FD0\u7EF4\u5DE5\u7A0B\u5E08",titleEn:"DevOps Engineer",group:"dev",actions:[{id:"deployment",name:"\u90E8\u7F72\u5BA1\u67E5",nameEn:"Deployment Review"},{id:"cicd",name:"CI/CD \u8BC4\u4F30",nameEn:"CI/CD Review"},{id:"infra",name:"\u57FA\u7840\u8BBE\u65BD",nameEn:"Infrastructure"}]},gregg:{id:"gregg",name:"Gregg",fullName:"Brendan Gregg",title:"\u6027\u80FD\u5DE5\u7A0B\u5E08",titleEn:"Performance Engineer",group:"dev",actions:[{id:"perf-analysis",name:"\u6027\u80FD\u5206\u6790",nameEn:"Perf Analysis"},{id:"tuning",name:"\u7CFB\u7EDF\u8C03\u4F18",nameEn:"Tuning"},{id:"benchmark",name:"\u57FA\u51C6\u6D4B\u8BD5",nameEn:"Benchmark"}]},codd:{id:"codd",name:"Codd",fullName:"Edgar Codd",title:"\u6570\u636E\u5E93 / SQL \u4E13\u5BB6",titleEn:"Database / SQL Expert",group:"dev",actions:[{id:"sql-optimization",name:"SQL \u4F18\u5316",nameEn:"SQL Optimization"},{id:"schema-design",name:"Schema \u8BBE\u8BA1",nameEn:"Schema Design"},{id:"data-modeling",name:"\u6570\u636E\u5EFA\u6A21",nameEn:"Data Modeling"}]},knuth:{id:"knuth",name:"Knuth",fullName:"Donald Knuth",title:"\u7B97\u6CD5 / \u6570\u636E\u5904\u7406\u4E13\u5BB6",titleEn:"Algorithm Expert",group:"dev",actions:[{id:"algorithm-design",name:"\u7B97\u6CD5\u8BBE\u8BA1",nameEn:"Algorithm Design"},{id:"data-processing",name:"\u6570\u636E\u5904\u7406",nameEn:"Data Processing"},{id:"optimization",name:"\u4F18\u5316",nameEn:"Optimization"}]},thomas:{id:"thomas",name:"Thomas",fullName:"Dave Thomas",title:"\u6280\u672F\u6587\u6863\u5DE5\u7A0B\u5E08",titleEn:"Tech Doc Engineer",group:"dev",actions:[{id:"api-docs",name:"API \u6587\u6863",nameEn:"API Docs"},{id:"readme",name:"README",nameEn:"README"},{id:"comment-review",name:"\u6CE8\u91CA\u5BA1\u67E5",nameEn:"Comment Review"}]},soros:{id:"soros",name:"Soros",fullName:"George Soros",title:"\u5B8F\u89C2\u7B56\u7565\u5E08",titleEn:"Macro Strategist",group:"trading",actions:[{id:"macro-analysis",name:"\u5B8F\u89C2\u5206\u6790",nameEn:"Macro Analysis"},{id:"risk-assessment",name:"\u98CE\u9669\u8BC4\u4F30",nameEn:"Risk Assessment"},{id:"thesis-review",name:"\u8BBA\u70B9\u5BA1\u67E5",nameEn:"Thesis Review"}]},livermore:{id:"livermore",name:"Livermore",fullName:"Jesse Livermore",title:"\u6280\u672F\u5206\u6790\u5E08",titleEn:"Technical Analyst",group:"trading",actions:[{id:"price-action",name:"\u4EF7\u683C\u884C\u4E3A",nameEn:"Price Action"},{id:"pattern-recognition",name:"\u56FE\u5F62\u8BC6\u522B",nameEn:"Pattern Recognition"},{id:"trade-plan",name:"\u4EA4\u6613\u8BA1\u5212",nameEn:"Trade Plan"}]},dalio:{id:"dalio",name:"Dalio",fullName:"Ray Dalio",title:"\u7814\u7A76\u5458 / \u7ECF\u6D4E\u5206\u6790\u5E08",titleEn:"Research / Economist",group:"trading",actions:[{id:"economic-analysis",name:"\u7ECF\u6D4E\u5206\u6790",nameEn:"Economic Analysis"},{id:"portfolio-review",name:"\u7EC4\u5408\u5BA1\u67E5",nameEn:"Portfolio Review"},{id:"research-report",name:"\u7814\u7A76\u62A5\u544A",nameEn:"Research Report"}]},taleb:{id:"taleb",name:"Taleb",fullName:"Nassim Taleb",title:"\u98CE\u63A7\u5B98",titleEn:"Risk Manager",group:"trading",actions:[{id:"risk-audit",name:"\u98CE\u9669\u5BA1\u8BA1",nameEn:"Risk Audit"},{id:"antifragile",name:"\u53CD\u8106\u5F31\u8BC4\u4F30",nameEn:"Antifragile Assessment"},{id:"stress-test",name:"\u538B\u529B\u6D4B\u8BD5",nameEn:"Stress Test"}]},jones:{id:"jones",name:"Jones",fullName:"Paul Tudor Jones",title:"\u4EA4\u6613\u6267\u884C\u5458",titleEn:"Trade Executor",group:"trading",actions:[{id:"execution",name:"\u6267\u884C\u8BA1\u5212",nameEn:"Execution Plan"},{id:"position-sizing",name:"\u4ED3\u4F4D\u8BA1\u7B97",nameEn:"Position Sizing"},{id:"trade-review",name:"\u4EA4\u6613\u590D\u76D8",nameEn:"Trade Review"}]},simons:{id:"simons",name:"Simons",fullName:"Jim Simons",title:"\u91CF\u5316\u5206\u6790\u5E08",titleEn:"Quant Analyst",group:"trading",actions:[{id:"quant-signal",name:"\u91CF\u5316\u4FE1\u53F7",nameEn:"Quant Signal"},{id:"backtest-review",name:"\u56DE\u6D4B\u5BA1\u67E5",nameEn:"Backtest Review"},{id:"model-design",name:"\u6A21\u578B\u8BBE\u8BA1",nameEn:"Model Design"}]},jinyong:{id:"jinyong",name:"\u91D1\u5EB8",fullName:"\u91D1\u5EB8\uFF08Louis Cha\uFF09",title:"\u6B66\u4FA0\u5927\u5E08",titleEn:"Wuxia Master",group:"writing",actions:[{id:"world-building",name:"\u6B66\u4FA0\u4E16\u754C\u89C2",nameEn:"Wuxia World Building"},{id:"character-design",name:"\u4EBA\u7269\u5851\u9020",nameEn:"Character Design"},{id:"plot-design",name:"\u60C5\u8282\u7F16\u6392",nameEn:"Plot Design"}]},zhouzi:{id:"zhouzi",name:"\u8098\u5B50",fullName:"\u4F1A\u8BF4\u8BDD\u7684\u8098\u5B50",title:"\u7F51\u6587\u5929\u738B",titleEn:"Web Novel King",group:"writing",actions:[{id:"cool-factor",name:"\u723D\u611F\u8BBE\u8BA1",nameEn:"Cool Factor Design"},{id:"pacing",name:"\u8282\u594F\u628A\u63A7",nameEn:"Pacing Control"},{id:"cheat-design",name:"\u91D1\u624B\u6307\u8BBE\u8BA1",nameEn:"Cheat System Design"}]},qiongyao:{id:"qiongyao",name:"\u743C\u7476",fullName:"\u743C\u7476\uFF08Chiung Yao\uFF09",title:"\u8A00\u60C5\u5B97\u5E08",titleEn:"Romance Master",group:"writing",actions:[{id:"emotion-writing",name:"\u60C5\u611F\u63CF\u5199",nameEn:"Emotion Writing"},{id:"dialogue-design",name:"\u5BF9\u8BDD\u8BBE\u8BA1",nameEn:"Dialogue Design"},{id:"romance-arc",name:"\u8650\u604B\u67B6\u6784",nameEn:"Romance Arc"}]},luxun:{id:"luxun",name:"\u9C81\u8FC5",fullName:"\u9C81\u8FC5\uFF08Lu Xun\uFF09",title:"\u6587\u5B66\u5DE8\u5320",titleEn:"Literary Giant",group:"writing",actions:[{id:"satire",name:"\u8BBD\u523A\u5199\u4F5C",nameEn:"Satirical Writing"},{id:"character-sketch",name:"\u4EBA\u7269\u523B\u753B",nameEn:"Character Sketch"},{id:"prose-craft",name:"\u6587\u7B14\u9524\u70BC",nameEn:"Prose Craft"}]},kubrick:{id:"kubrick",name:"Kubrick",fullName:"Stanley Kubrick",title:"\u5BFC\u6F14 / \u89C6\u89C9\u603B\u76D1",titleEn:"Director / Visual Director",group:"video",actions:[{id:"narrative-pacing",name:"\u53D9\u4E8B\u8282\u594F",nameEn:"Narrative Pacing"},{id:"visual-concept",name:"\u89C6\u89C9\u6982\u5FF5",nameEn:"Visual Concept"},{id:"scene-breakdown",name:"\u573A\u666F\u62C6\u89E3",nameEn:"Scene Breakdown"}]},kaufman:{id:"kaufman",name:"Kaufman",fullName:"Charlie Kaufman",title:"\u7F16\u5267",titleEn:"Screenwriter",group:"video",actions:[{id:"script-writing",name:"\u811A\u672C\u5199\u4F5C",nameEn:"Script Writing"},{id:"character-design",name:"\u89D2\u8272\u8BBE\u8BA1",nameEn:"Character Design"},{id:"narrative-structure",name:"\u53D9\u4E8B\u7ED3\u6784",nameEn:"Narrative Structure"}]},spielberg:{id:"spielberg",name:"Spielberg",fullName:"Steven Spielberg",title:"\u5206\u955C / \u89C6\u89C9\u53D9\u4E8B\u5E08",titleEn:"Storyboard / Visual Storyteller",group:"video",actions:[{id:"storyboard",name:"\u5206\u955C\u8BBE\u8BA1",nameEn:"Storyboard"},{id:"shot-design",name:"\u955C\u5934\u65B9\u6848",nameEn:"Shot Design"},{id:"visual-storytelling",name:"\u89C6\u89C9\u53D9\u4E8B",nameEn:"Visual Storytelling"}]},schoonmaker:{id:"schoonmaker",name:"Schoonmaker",fullName:"Thelma Schoonmaker",title:"\u526A\u8F91\u5E08",titleEn:"Editor",group:"video",actions:[{id:"editing-rhythm",name:"\u526A\u8F91\u8282\u594F",nameEn:"Editing Rhythm"},{id:"sequence-design",name:"\u5E8F\u5217\u8BBE\u8BA1",nameEn:"Sequence Design"},{id:"final-cut",name:"\u6700\u7EC8\u5BA1\u7247",nameEn:"Final Cut"}]}};Xc="dev",os=3});function fh(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function Jc(){return`cm_${crypto.randomUUID()}`}function ed(e,t){if(t===e.currentAgent&&!e.pendingAgentSelection)return;let s=`agent_select_${crypto.randomUUID()}`;return e.agentSwitching=!0,e.pendingAgentSelection={agentId:t,requestId:s},e.sendWsMessage({type:"select_agent",agentId:t,requestId:s})===!1?(e.pendingAgentSelection=null,e.agentSwitching=!1,null):s}function td(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}_s(e,!0,Ee("chat.session.creating"));let o={type:"create_conversation",agentId:i,workDir:t||e.currentAgentWorkDir};n!==null&&(o.disallowedTools=n),r&&typeof r.provider=="string"&&(o.provider=r.provider),r&&r.providerOptions&&typeof r.providerOptions=="object"&&(o.providerOptions=r.providerOptions),e.sendWsMessage(o)}function sd(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}let a=null,l={};r&&typeof r=="object"&&!Array.isArray(r)?l=r:(a=r,i&&typeof i=="object"&&(l=i)),_s(e,!0,Ee("chat.session.loadingHistory"));let c={type:"resume_conversation",agentId:o,claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(c.disallowedTools=a),typeof l.provider=="string"&&(c.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(c.providerOptions=l.providerOptions),e.sendWsMessage(c)}function nd(e,t,s){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t);return}if(t===e.currentConversation)return;let n=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(n&&n.agentId&&n.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===n.agentId);a&&(e.currentAgent=n.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:n.agentId,silent:!0}))}e.sendWsMessage({type:"select_conversation",conversationId:t}),e.panels.length>1?e.activeConversations.includes(t)||e.activeConversations.push(t):e.activeConversations=[t],n&&(e.currentWorkDir=n.workDir);let r=e.messagesMap[t],i=ss(r);i!==null?e.requestChatHistory?.(t,{mode:"delta",afterMessageId:i}):((!r||r.length===0)&&(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory"))),e.requestChatHistory?.(t,{mode:"recent",turns:5})),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,Es(e)}function qo(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function rd(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let f=r.find(p=>p.name===t);f&&(f.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let f of i)if(!f.enabled){let p=o[f.name];p&&p.length>0?a.push(...p):a.push(`mcp__${f.name}`)}let u=[...(e.conversations.find(f=>f.id===n)?.disallowedTools||[]).filter(f=>!f.startsWith("mcp__")),...a];qo(e,n,{disallowedTools:u})}function id(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function od(e,t,s){e._recentlyDeletedSessions||(e._recentlyDeletedSessions={}),e._recentlyDeletedSessions[t]=Date.now(),e.conversations=e.conversations.filter(i=>i.id!==t);let n=e.activeConversations.indexOf(t);n>=0&&(e.activeConversations.splice(n,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null));for(let i of e.panels)i.conversationId===t&&(i.conversationId=null);let r=e.pinnedSessions.indexOf(t);r>=0&&(e.pinnedSessions.splice(r,1),localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions))),e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}})}function ad(e,t,s=[],n={}){let r=n.expertSelections&&n.expertSelections.length>0;if(!t.trim()&&s.length===0&&!r||!e.currentAgent||!e.currentConversation)return;let i=Jc();if(e.addMessage({type:"user",content:t,clientMessageId:i,attachments:s.length>0?s:void 0,expertSelections:r?n.expertSelections:void 0}),t.trim()){let c=t.trim().substring(0,100);e.conversationTitles[e.currentConversation]=c}else if(r){let c=n.expertSelections[0],d=`@${c.role}${c.action?"\xB7"+c.action:""}`;e.conversationTitles[e.currentConversation]=d}let o=e.conversations.find(c=>c.id===e.currentConversation);o&&(o.lastMessageAt=Date.now()),e.processingConversations[e.currentConversation]||(e.processingConversations[e.currentConversation]=!0,e._closedAt?.[e.currentConversation]&&delete e._closedAt[e.currentConversation],e._turnCompletedConvs?.delete(e.currentConversation),e.getOrCreateExecutionStatus(e.currentConversation),Ls(e,e.currentConversation));let a=s.map(c=>c.fileId),l={type:"chat",conversationId:e.currentConversation,prompt:t,fileIds:a,workDir:e.currentWorkDir,clientMessageId:i};if(n.targetRole&&(l.targetRole=n.targetRole),r){l.expertSelections=n.expertSelections;let c=Ho(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||bn(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ae(e,e.currentConversation)})}function ld(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Bt(e,t),e.addMessage({type:"system",content:Ee("chat.execution.cancelled")})}function cd(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(g=>g.type==="tool-use"&&g.toolName==="AskUserQuestion"&&g.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&o?.askPending)return;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?fh(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let f=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||f||e.yeaftAgentId||e.currentAgent||null,conversationId:r,requestId:t,toolCallId:o?.toolId||null,answers:s,sessionId:l,vpId:o?.vpId||o?.speakerVpId||null,turnId:o?.turnId||null,threadId:o?.threadId||"main"}:{type:"ask_user_answer",conversationId:r,requestId:t,answers:s});if(o&&!a)o.askAnswered=!0,o.selectedAnswers=s;else if(o&&p!==!1){let g=++ph;o.askPending=!0,o.pendingAnswers=s,o.askSubmitGeneration=g;let b=setTimeout(()=>{o.askSubmitGeneration!==g||o.askPending!==!0||(o.askPending=!1,o.pendingAnswers=null,o.askSubmitGeneration=null)},uh);typeof b?.unref=="function"&&b.unref()}p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function dd(e,t){t&&(e.activeConversations.includes(t)||e.activeConversations.length>=3||(e.activeConversations.push(t),e.messagesMap[t]||(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5})),Es(e)))}function ud(e,t){let s=e.activeConversations.indexOf(t);s<0||(e.activeConversations.splice(s,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null),Es(e))}function pd(e,t,s,n=[],r={}){let i=r.expertSelections&&r.expertSelections.length>0;if(!s.trim()&&n.length===0&&!i||!e.currentAgent||!t)return;let o=Jc();if(e.addMessageToConversation(t,{type:"user",content:s,clientMessageId:o,attachments:n.length>0?n:void 0,expertSelections:i?r.expertSelections:void 0}),s.trim()){let d=s.trim().substring(0,100);e.conversationTitles[t]=d}else if(i){let d=r.expertSelections[0],u=`@${d.role}${d.action?"\xB7"+d.action:""}`;e.conversationTitles[t]=u}let a=e.conversations.find(d=>d.id===t);a&&(a.lastMessageAt=Date.now()),e.processingConversations[t]||(e.processingConversations[t]=!0,e._closedAt?.[t]&&delete e._closedAt[t],e._turnCompletedConvs?.delete(t),e.getOrCreateExecutionStatus(t),Ls(e,t));let l=n.map(d=>d.fileId),c={type:"chat",conversationId:t,prompt:s,fileIds:l,workDir:a?.workDir||e.currentWorkDir,clientMessageId:o};if(r.targetRole&&(c.targetRole=r.targetRole),i){c.expertSelections=r.expertSelections;let d=Ho(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||bn(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ae(e,t)})}function fd(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Bt(e,t),e.addMessageToConversation(t,{type:"system",content:Ee("chat.execution.cancelled")})}function gd(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function md(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function hd(e,t){t&&e.sendWsMessage({type:"restart_agent",agentId:t})}function vd(e,t){t&&e.sendWsMessage({type:"upgrade_agent",agentId:t})}var uh,ph,yd=F(()=>{Nt();ts();po();Rr();Ds();xt();_n();uh=1e4,ph=0});function mh(e=globalThis.localStorage){try{return e?.getItem(wd)==="yeaft"?"yeaft":bd}catch{return bd}}function No(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(wd,e),!!t}catch{return!1}}function kd(e=globalThis.localStorage){let t=mh(e);if(t!=="yeaft")return{currentView:t,_yeaftTransitionActive:!1,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:null};let s=null;try{s=e?.getItem("lastViewedConversation")||null}catch{}let n=s&&!s.startsWith("yeaft-")?s:null;return{currentView:t,_yeaftTransitionActive:!0,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:n}}function Bo(e){return e._yeaftTransitionActive?!1:(e._savedActiveConversations=[...e.activeConversations],e._savedChatIdentity={agentId:e.currentAgent||null,agentInfo:e.currentAgentInfo?{...e.currentAgentInfo}:null,workDir:e.currentWorkDir||null},e._yeaftTransitionActive=!0,!0)}function Sd(e){let t=Bo(e);return e.activeConversations=[e.yeaftConversationId],t}function Id(e){if(!e._yeaftTransitionActive)return null;let t=e._savedChatIdentity||null;return e.activeConversations=e._savedActiveConversations||[],t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.currentWorkDir=t.workDir),e._savedActiveConversations=null,e._savedChatIdentity=null,e._yeaftTransitionActive=!1,t}var wd,bd,Cd=F(()=>{wd="yeaft-preferred-conversation-view",bd="chat"});function Ad(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function xd(e,t,s){let n={...e||{}},r={...n[t]||{}},i=(r[s]||0)-1;return i<=0?delete r[s]:r[s]=i,Object.keys(r).length===0?delete n[t]:n[t]=r,n}var Td=F(()=>{});function Wo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var Md=F(()=>{});function Pd({loops:e,turnsById:t,turnOrder:s,maxLoops:n}){if(!Array.isArray(e)||e.length<=n)return{loops:e,turnsById:t,turnOrder:s};let r=e.length-n,i=e.slice(r),o=new Set;for(let c of i)c&&c.turnId&&o.add(c.turnId);for(let c of s){let d=t[c];d&&d.closedAt==null&&o.add(c)}let a={};for(let c of Object.keys(t))o.has(c)&&(a[c]=t[c]);let l=s.filter(c=>o.has(c));return{loops:i,turnsById:a,turnOrder:l}}var Rd=F(()=>{});function Re(e){let t=Number(e);return Number.isFinite(t)?t:null}function Hs(e){let t=Re(e);return Number.isInteger(t)&&t>0?t:null}function Uo(e){let t=Re(e);return Number.isInteger(t)&&t>=0?t:null}function _d(e){return yh.has(e)?1:0}function bh(e,t){if(!e)return t||null;if(!t)return e;let s=Re(e.progressRevision),n=Re(t.progressRevision);if(s!=null||n!=null){if(s==null)return t;if(n==null)return e;if(s!==n)return n>s?t:e}let r=_d(e.status),i=_d(t.status);if(r!==i)return i>r?t:e;let o=Re(e.updatedAt)??Re(e.createdAt)??0;return(Re(t.updatedAt)??Re(t.createdAt)??0)>o?t:e}function Os(e){return Math.max(0,Number(e)||0)}function Ed(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function wh(e,t){if(/^\d+$/.test(e)&&/^\d+$/.test(t)){let s=BigInt(e),n=BigInt(t);return s<n?-1:s>n?1:0}return e.localeCompare(t)}function kh(e,t){let s=Os(e?.createdAt)-Os(t?.createdAt);if(s)return s;let n=Ed(e),r=Ed(t);if(n!=null&&r!=null)return wh(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Os(e?.generation)-Os(t?.generation);return a||Os(e?.attempt)-Os(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function En(...e){let t=new Map;for(let s of e){let n=Array.isArray(s)?s:[s];for(let r of n)r?.id&&t.set(r.id,bh(t.get(r.id),r))}return[...t.values()].sort(kh)}function tt(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function qs(e,t,s,n){return`${e}:${t}:${s}:${tt(n)}`}function Dn(e,t,s,n){return`${e}:${t}:${s}:${tt(n)}`}function Ns(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);if(s!=null&&n!=null&&s!==n)return s<n;let r=Re(e.coordinatorRevision),i=Re(t.coordinatorRevision);if(r!=null&&i!=null&&r!==i)return r<i;let o=Re(e.updatedAt),a=Re(t.updatedAt);return o!=null&&a!=null&&o<a}function Dd(e,t){if(Ns(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function jo(e,t){let s=Hs(e?.generation),n=Hs(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=Uo(e?.attempt),i=Uo(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=Re(e?.progressRevision),a=Re(t?.progressRevision);return o!=null&&a!=null&&a<o}function zo(e,t){if(!e||e.id!==t?.id||Ns(t,e))return null;let s=Array.isArray(e.actions)?e.actions:[],n=Array.isArray(t.actionStats)?t.actionStats:[],r=e.currentActionId||null,i=Object.prototype.hasOwnProperty.call(t,"currentActionId")?t.currentActionId||null:r,o=typeof t.eventActionId=="string"&&n.some(g=>g?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(g=>g?.id===a)||null,c=n.find(g=>g?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&jo(l,c))return null;let d=Hs(l?.generation),u=Hs(c?.generation),f=Uo(c?.attempt),p={actionId:a,generation:u||d||1,...f==null?{}:{attempt:f}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Ld(e,t){if(!e||e.id!==t?.id||Ns(t,e))return!1;let s=Re(t.coordinatorRevision),n=Re(e.coordinatorRevision)??0;return s!=null&&s>n?!0:zo(e,t)!=null}function $d(e,t){if(!e||e.id!==t?.id||Ns(t,e))return e;let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let r=new Map(t.actionStats.map(o=>[o?.id,o])),i=!1;n=!0,s.actions=e.actions.map(o=>{let a=r.get(o?.id);if(!a)return o;if(i=!0,jo(o,a))return n=!1,o;if(Re(a?.progressRevision)==null){let{response:u,messages:f,...p}=a;return{...o,...p}}let c=Hs(o?.generation),d=Hs(a?.generation);if(c!=null&&d!=null&&d>c){let{messages:u,thread:f,liveMessage:p,response:g,failure:b,messageCursor:h,messageCount:A,failureReason:w,...S}=o;return{...S,...a}}return{...o,...a}}),i||(n=!1)}for(let r of vh)!n&&Sh.has(r)||Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r]);return s}function Vd(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let s=new Map(e.map(n=>[n?.id,n]));return t.some(n=>{let r=s.get(n?.id);return r?jo(r,n):!1})}function Fd(e,t){return Re(e?.revision)===Re(t?.revision)&&Re(e?.coordinatorRevision)===Re(t?.coordinatorRevision)&&Re(e?.updatedAt)===Re(t?.updatedAt)}function Od(e,t){return!e||!t||e.id!==t.id?!1:Ns(e,t)?!0:Fd(t,e)&&Vd(t.actions,e.actions)}function Er(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Ns(t,n)?n:t;return n&&r===t&&Fd(n,t)&&Vd(n.actionStats,t.actionStats)&&(r=n),r?.id?[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0)):s}var vh,yh,Sh,Ko=F(()=>{vh=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);yh=new Set(["completed","failed","cancelled","superseded","interrupted"]);Sh=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function as(e){return typeof e=="string"?e.trim():""}function Hd(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e=="string"&&e.trim()){let t=Date.parse(e);if(Number.isFinite(t))return t}return null}function vt(e){let t=Hd(e);if(!t)return"";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch{return""}}function Ih(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:as(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...as(t?.activeForm)?{activeForm:as(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Dr(e){if(!e||typeof e!="object")return null;let t=as(e.content).slice(0,1e5),s=Ih(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Hd(e.timestamp);return{id:as(e.id).slice(0,256)||null,role:n,author:as(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function qd(e,t){return Dr({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function Nd(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(o=>as(o?.toolName)).filter(Boolean):[],r=Number(e?.toolSummaryCount||0)||0,i=n.length>0?`Tool actions: ${n.join(", ")}`:r>0?`Tool actions: ${r}`:"";return Dr({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||i,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var ls=F(()=>{});function Bd(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t?.type==="text"&&typeof t.text=="string"?t.text:"").join(""):e==null?"":String(e)}function Ch(e,t){if(!e||e.type!=="assistant")return!1;let s=e.sessionId??e.groupId??null,n=e.speakerVpId||e.vpId||null;return!(t.sessionId&&s!==t.sessionId||t.vpId&&n!==t.vpId||t.turnId&&e.turnId!==t.turnId)}function Wd(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Ch(n,t));if(s.length===0)return!1;for(let n of s)n.responseKind="progress";if(t.reason==="end_turn"){for(let n=s.length-1;n>=0;n-=1)if(Bd(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function Lr(e,t){if(!e||!t)return;let s=Bd(t.content);s&&(Array.isArray(e.textSegments)||(e.textSegments=[]),e.textSegments.push({key:t.messageId||t.id||`response-${e.textSegments.length}`,content:s,kind:t.responseKind==="result"?"result":"progress",explicitKind:t.responseKind==="progress"||t.responseKind==="result",isStreaming:t.isStreaming===!0}),e.textContent=e.textSegments.map(n=>n.content).join(`
|
|
6
|
+
`)+(s||"")}}function Zc(e){return Object.values(Yc).filter(t=>e||!t.adminOnly).sort((t,s)=>t.order-s.order)}var Yc,ut,Xc,as,_n=F(()=>{Yc={dev:{id:"dev",name:"\u8F6F\u4EF6\u5F00\u53D1",nameEn:"Software Dev",icon:"\u{1F5A5}\uFE0F",order:0},trading:{id:"trading",name:"\u4EA4\u6613",nameEn:"Trading",icon:"\u{1F4C8}",order:1,adminOnly:!0},writing:{id:"writing",name:"\u5199\u4F5C",nameEn:"Writing",icon:"\u270D\uFE0F",order:2,adminOnly:!0},video:{id:"video",name:"\u89C6\u9891",nameEn:"Video",icon:"\u{1F3AC}",order:3,adminOnly:!0}},ut={jobs:{id:"jobs",name:"Jobs",fullName:"Steve Jobs",title:"\u4EA7\u54C1\u7ECF\u7406",titleEn:"Product Manager",group:"dev",actions:[{id:"product-analysis",name:"\u4EA7\u54C1\u5206\u6790",nameEn:"Product Analysis"},{id:"design-review",name:"\u8BBE\u8BA1\u5BA1\u67E5",nameEn:"Design Review"},{id:"requirements",name:"\u9700\u6C42\u62C6\u89E3",nameEn:"Requirements"}]},fowler:{id:"fowler",name:"Fowler",fullName:"Martin Fowler",title:"\u8F6F\u4EF6\u67B6\u6784\u5E08",titleEn:"Software Architect",group:"dev",actions:[{id:"architecture",name:"\u67B6\u6784\u5BA1\u67E5",nameEn:"Architecture Review"},{id:"refactoring",name:"\u91CD\u6784\u5206\u6790",nameEn:"Refactoring"},{id:"code-review",name:"\u4EE3\u7801\u5BA1\u67E5",nameEn:"Code Review"}]},torvalds:{id:"torvalds",name:"Torvalds",fullName:"Linus Torvalds",title:"\u7CFB\u7EDF\u5F00\u53D1\u5DE5\u7A0B\u5E08",titleEn:"Systems Engineer",group:"dev",actions:[{id:"system-design",name:"\u7CFB\u7EDF\u8BBE\u8BA1",nameEn:"System Design"},{id:"performance",name:"\u6027\u80FD\u4F18\u5316",nameEn:"Performance"},{id:"code-style",name:"\u4EE3\u7801\u98CE\u683C",nameEn:"Code Style"},{id:"implementation",name:"\u4EE3\u7801\u5B9E\u73B0",nameEn:"Implementation"}]},beck:{id:"beck",name:"Beck",fullName:"Kent Beck",title:"\u6D4B\u8BD5\u5DE5\u7A0B\u5E08",titleEn:"Test Engineer",group:"dev",actions:[{id:"test-strategy",name:"\u6D4B\u8BD5\u7B56\u7565",nameEn:"Test Strategy"},{id:"tdd-guide",name:"TDD \u6307\u5BFC",nameEn:"TDD Guide"},{id:"quality-check",name:"\u8D28\u91CF\u8BC4\u4F30",nameEn:"Quality Check"}]},schneier:{id:"schneier",name:"Schneier",fullName:"Bruce Schneier",title:"\u5B89\u5168\u5DE5\u7A0B\u5E08",titleEn:"Security Engineer",group:"dev",actions:[{id:"security-audit",name:"\u5B89\u5168\u5BA1\u8BA1",nameEn:"Security Audit"},{id:"threat-model",name:"\u5A01\u80C1\u5EFA\u6A21",nameEn:"Threat Model"},{id:"auth-review",name:"\u8BA4\u8BC1\u5BA1\u67E5",nameEn:"Auth Review"}]},rams:{id:"rams",name:"Rams",fullName:"Dieter Rams",title:"UI/UX \u8BBE\u8BA1\u5E08",titleEn:"UI/UX Designer",group:"dev",actions:[{id:"ui-review",name:"\u754C\u9762\u5BA1\u67E5",nameEn:"UI Review"},{id:"interaction",name:"\u4EA4\u4E92\u8BBE\u8BA1",nameEn:"Interaction Design"},{id:"layout",name:"\u5E03\u5C40\u4F18\u5316",nameEn:"Layout Optimization"}]},graham:{id:"graham",name:"Graham",fullName:"Paul Graham",title:"\u6280\u672F\u5199\u4F5C / \u65B9\u6848\u8BC4\u4F30\u5E08",titleEn:"Tech Writer / Evaluator",group:"dev",actions:[{id:"writing",name:"\u6280\u672F\u5199\u4F5C",nameEn:"Tech Writing"},{id:"proposal-review",name:"\u65B9\u6848\u8BC4\u4F30",nameEn:"Proposal Review"},{id:"explain",name:"\u6982\u5FF5\u89E3\u91CA",nameEn:"Explain"}]},hightower:{id:"hightower",name:"Hightower",fullName:"Kelsey Hightower",title:"DevOps / \u8FD0\u7EF4\u5DE5\u7A0B\u5E08",titleEn:"DevOps Engineer",group:"dev",actions:[{id:"deployment",name:"\u90E8\u7F72\u5BA1\u67E5",nameEn:"Deployment Review"},{id:"cicd",name:"CI/CD \u8BC4\u4F30",nameEn:"CI/CD Review"},{id:"infra",name:"\u57FA\u7840\u8BBE\u65BD",nameEn:"Infrastructure"}]},gregg:{id:"gregg",name:"Gregg",fullName:"Brendan Gregg",title:"\u6027\u80FD\u5DE5\u7A0B\u5E08",titleEn:"Performance Engineer",group:"dev",actions:[{id:"perf-analysis",name:"\u6027\u80FD\u5206\u6790",nameEn:"Perf Analysis"},{id:"tuning",name:"\u7CFB\u7EDF\u8C03\u4F18",nameEn:"Tuning"},{id:"benchmark",name:"\u57FA\u51C6\u6D4B\u8BD5",nameEn:"Benchmark"}]},codd:{id:"codd",name:"Codd",fullName:"Edgar Codd",title:"\u6570\u636E\u5E93 / SQL \u4E13\u5BB6",titleEn:"Database / SQL Expert",group:"dev",actions:[{id:"sql-optimization",name:"SQL \u4F18\u5316",nameEn:"SQL Optimization"},{id:"schema-design",name:"Schema \u8BBE\u8BA1",nameEn:"Schema Design"},{id:"data-modeling",name:"\u6570\u636E\u5EFA\u6A21",nameEn:"Data Modeling"}]},knuth:{id:"knuth",name:"Knuth",fullName:"Donald Knuth",title:"\u7B97\u6CD5 / \u6570\u636E\u5904\u7406\u4E13\u5BB6",titleEn:"Algorithm Expert",group:"dev",actions:[{id:"algorithm-design",name:"\u7B97\u6CD5\u8BBE\u8BA1",nameEn:"Algorithm Design"},{id:"data-processing",name:"\u6570\u636E\u5904\u7406",nameEn:"Data Processing"},{id:"optimization",name:"\u4F18\u5316",nameEn:"Optimization"}]},thomas:{id:"thomas",name:"Thomas",fullName:"Dave Thomas",title:"\u6280\u672F\u6587\u6863\u5DE5\u7A0B\u5E08",titleEn:"Tech Doc Engineer",group:"dev",actions:[{id:"api-docs",name:"API \u6587\u6863",nameEn:"API Docs"},{id:"readme",name:"README",nameEn:"README"},{id:"comment-review",name:"\u6CE8\u91CA\u5BA1\u67E5",nameEn:"Comment Review"}]},soros:{id:"soros",name:"Soros",fullName:"George Soros",title:"\u5B8F\u89C2\u7B56\u7565\u5E08",titleEn:"Macro Strategist",group:"trading",actions:[{id:"macro-analysis",name:"\u5B8F\u89C2\u5206\u6790",nameEn:"Macro Analysis"},{id:"risk-assessment",name:"\u98CE\u9669\u8BC4\u4F30",nameEn:"Risk Assessment"},{id:"thesis-review",name:"\u8BBA\u70B9\u5BA1\u67E5",nameEn:"Thesis Review"}]},livermore:{id:"livermore",name:"Livermore",fullName:"Jesse Livermore",title:"\u6280\u672F\u5206\u6790\u5E08",titleEn:"Technical Analyst",group:"trading",actions:[{id:"price-action",name:"\u4EF7\u683C\u884C\u4E3A",nameEn:"Price Action"},{id:"pattern-recognition",name:"\u56FE\u5F62\u8BC6\u522B",nameEn:"Pattern Recognition"},{id:"trade-plan",name:"\u4EA4\u6613\u8BA1\u5212",nameEn:"Trade Plan"}]},dalio:{id:"dalio",name:"Dalio",fullName:"Ray Dalio",title:"\u7814\u7A76\u5458 / \u7ECF\u6D4E\u5206\u6790\u5E08",titleEn:"Research / Economist",group:"trading",actions:[{id:"economic-analysis",name:"\u7ECF\u6D4E\u5206\u6790",nameEn:"Economic Analysis"},{id:"portfolio-review",name:"\u7EC4\u5408\u5BA1\u67E5",nameEn:"Portfolio Review"},{id:"research-report",name:"\u7814\u7A76\u62A5\u544A",nameEn:"Research Report"}]},taleb:{id:"taleb",name:"Taleb",fullName:"Nassim Taleb",title:"\u98CE\u63A7\u5B98",titleEn:"Risk Manager",group:"trading",actions:[{id:"risk-audit",name:"\u98CE\u9669\u5BA1\u8BA1",nameEn:"Risk Audit"},{id:"antifragile",name:"\u53CD\u8106\u5F31\u8BC4\u4F30",nameEn:"Antifragile Assessment"},{id:"stress-test",name:"\u538B\u529B\u6D4B\u8BD5",nameEn:"Stress Test"}]},jones:{id:"jones",name:"Jones",fullName:"Paul Tudor Jones",title:"\u4EA4\u6613\u6267\u884C\u5458",titleEn:"Trade Executor",group:"trading",actions:[{id:"execution",name:"\u6267\u884C\u8BA1\u5212",nameEn:"Execution Plan"},{id:"position-sizing",name:"\u4ED3\u4F4D\u8BA1\u7B97",nameEn:"Position Sizing"},{id:"trade-review",name:"\u4EA4\u6613\u590D\u76D8",nameEn:"Trade Review"}]},simons:{id:"simons",name:"Simons",fullName:"Jim Simons",title:"\u91CF\u5316\u5206\u6790\u5E08",titleEn:"Quant Analyst",group:"trading",actions:[{id:"quant-signal",name:"\u91CF\u5316\u4FE1\u53F7",nameEn:"Quant Signal"},{id:"backtest-review",name:"\u56DE\u6D4B\u5BA1\u67E5",nameEn:"Backtest Review"},{id:"model-design",name:"\u6A21\u578B\u8BBE\u8BA1",nameEn:"Model Design"}]},jinyong:{id:"jinyong",name:"\u91D1\u5EB8",fullName:"\u91D1\u5EB8\uFF08Louis Cha\uFF09",title:"\u6B66\u4FA0\u5927\u5E08",titleEn:"Wuxia Master",group:"writing",actions:[{id:"world-building",name:"\u6B66\u4FA0\u4E16\u754C\u89C2",nameEn:"Wuxia World Building"},{id:"character-design",name:"\u4EBA\u7269\u5851\u9020",nameEn:"Character Design"},{id:"plot-design",name:"\u60C5\u8282\u7F16\u6392",nameEn:"Plot Design"}]},zhouzi:{id:"zhouzi",name:"\u8098\u5B50",fullName:"\u4F1A\u8BF4\u8BDD\u7684\u8098\u5B50",title:"\u7F51\u6587\u5929\u738B",titleEn:"Web Novel King",group:"writing",actions:[{id:"cool-factor",name:"\u723D\u611F\u8BBE\u8BA1",nameEn:"Cool Factor Design"},{id:"pacing",name:"\u8282\u594F\u628A\u63A7",nameEn:"Pacing Control"},{id:"cheat-design",name:"\u91D1\u624B\u6307\u8BBE\u8BA1",nameEn:"Cheat System Design"}]},qiongyao:{id:"qiongyao",name:"\u743C\u7476",fullName:"\u743C\u7476\uFF08Chiung Yao\uFF09",title:"\u8A00\u60C5\u5B97\u5E08",titleEn:"Romance Master",group:"writing",actions:[{id:"emotion-writing",name:"\u60C5\u611F\u63CF\u5199",nameEn:"Emotion Writing"},{id:"dialogue-design",name:"\u5BF9\u8BDD\u8BBE\u8BA1",nameEn:"Dialogue Design"},{id:"romance-arc",name:"\u8650\u604B\u67B6\u6784",nameEn:"Romance Arc"}]},luxun:{id:"luxun",name:"\u9C81\u8FC5",fullName:"\u9C81\u8FC5\uFF08Lu Xun\uFF09",title:"\u6587\u5B66\u5DE8\u5320",titleEn:"Literary Giant",group:"writing",actions:[{id:"satire",name:"\u8BBD\u523A\u5199\u4F5C",nameEn:"Satirical Writing"},{id:"character-sketch",name:"\u4EBA\u7269\u523B\u753B",nameEn:"Character Sketch"},{id:"prose-craft",name:"\u6587\u7B14\u9524\u70BC",nameEn:"Prose Craft"}]},kubrick:{id:"kubrick",name:"Kubrick",fullName:"Stanley Kubrick",title:"\u5BFC\u6F14 / \u89C6\u89C9\u603B\u76D1",titleEn:"Director / Visual Director",group:"video",actions:[{id:"narrative-pacing",name:"\u53D9\u4E8B\u8282\u594F",nameEn:"Narrative Pacing"},{id:"visual-concept",name:"\u89C6\u89C9\u6982\u5FF5",nameEn:"Visual Concept"},{id:"scene-breakdown",name:"\u573A\u666F\u62C6\u89E3",nameEn:"Scene Breakdown"}]},kaufman:{id:"kaufman",name:"Kaufman",fullName:"Charlie Kaufman",title:"\u7F16\u5267",titleEn:"Screenwriter",group:"video",actions:[{id:"script-writing",name:"\u811A\u672C\u5199\u4F5C",nameEn:"Script Writing"},{id:"character-design",name:"\u89D2\u8272\u8BBE\u8BA1",nameEn:"Character Design"},{id:"narrative-structure",name:"\u53D9\u4E8B\u7ED3\u6784",nameEn:"Narrative Structure"}]},spielberg:{id:"spielberg",name:"Spielberg",fullName:"Steven Spielberg",title:"\u5206\u955C / \u89C6\u89C9\u53D9\u4E8B\u5E08",titleEn:"Storyboard / Visual Storyteller",group:"video",actions:[{id:"storyboard",name:"\u5206\u955C\u8BBE\u8BA1",nameEn:"Storyboard"},{id:"shot-design",name:"\u955C\u5934\u65B9\u6848",nameEn:"Shot Design"},{id:"visual-storytelling",name:"\u89C6\u89C9\u53D9\u4E8B",nameEn:"Visual Storytelling"}]},schoonmaker:{id:"schoonmaker",name:"Schoonmaker",fullName:"Thelma Schoonmaker",title:"\u526A\u8F91\u5E08",titleEn:"Editor",group:"video",actions:[{id:"editing-rhythm",name:"\u526A\u8F91\u8282\u594F",nameEn:"Editing Rhythm"},{id:"sequence-design",name:"\u5E8F\u5217\u8BBE\u8BA1",nameEn:"Sequence Design"},{id:"final-cut",name:"\u6700\u7EC8\u5BA1\u7247",nameEn:"Final Cut"}]}};Xc="dev",as=3});function fh(e,t){return!t||!e?.yeaftConversationIdsByAgent?[]:Object.entries(e.yeaftConversationIdsByAgent).filter(([,s])=>s===t).map(([s])=>s).filter(Boolean)}function Jc(){return`cm_${crypto.randomUUID()}`}function ed(e,t){if(t===e.currentAgent&&!e.pendingAgentSelection)return;let s=`agent_select_${crypto.randomUUID()}`;return e.agentSwitching=!0,e.pendingAgentSelection={agentId:t,requestId:s},e.sendWsMessage({type:"select_agent",agentId:t,requestId:s})===!1?(e.pendingAgentSelection=null,e.agentSwitching=!1,null):s}function td(e,t,s=null,n=null,r={}){let i=s||e.currentAgent;if(!i){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}_s(e,!0,Ee("chat.session.creating"));let o={type:"create_conversation",agentId:i,workDir:t||e.currentAgentWorkDir};n!==null&&(o.disallowedTools=n),r&&typeof r.provider=="string"&&(o.provider=r.provider),r&&r.providerOptions&&typeof r.providerOptions=="object"&&(o.providerOptions=r.providerOptions),e.sendWsMessage(o)}function sd(e,t,s,n=null,r=null,i=null){let o=n||e.currentAgent;if(!o){e.addMessage({type:"error",content:Ee("chat.agent.selectFirst")});return}let a=null,l={};r&&typeof r=="object"&&!Array.isArray(r)?l=r:(a=r,i&&typeof i=="object"&&(l=i)),_s(e,!0,Ee("chat.session.loadingHistory"));let c={type:"resume_conversation",agentId:o,claudeSessionId:t,workDir:s||e.currentAgentWorkDir};a!==null&&(c.disallowedTools=a),typeof l.provider=="string"&&(c.provider=l.provider),l.providerOptions&&typeof l.providerOptions=="object"&&(c.providerOptions=l.providerOptions),e.sendWsMessage(c)}function nd(e,t,s){if(e.panels.length>1){let a=e.activePanelId||e.panels[0]?.id;a&&e.setPanelConversation(a,t);return}if(t===e.currentConversation)return;let n=e.conversations.find(a=>a.id===t&&a.type!=="yeaft");if(n&&n.agentId&&n.agentId!==e.currentAgent){let a=e.agents.find(l=>l.id===n.agentId);a&&(e.currentAgent=n.agentId,e.currentAgentInfo=a,e.sendWsMessage({type:"select_agent",agentId:n.agentId,silent:!0}))}e.sendWsMessage({type:"select_conversation",conversationId:t}),e.panels.length>1?e.activeConversations.includes(t)||e.activeConversations.push(t):e.activeConversations=[t],n&&(e.currentWorkDir=n.workDir);let r=e.messagesMap[t],i=ns(r);i!==null?e.requestChatHistory?.(t,{mode:"delta",afterMessageId:i}):((!r||r.length===0)&&(e.messagesMap[t]=[],_s(e,!0,Ee("chat.session.loadingHistory"))),e.requestChatHistory?.(t,{mode:"recent",turns:5})),e.loadingMoreMessages=!1;let o=e.chatSessionState[t];e.hasMoreMessages=!!o?.hasMoreOlder,Es(e)}function qo(e,t,s){t&&e.sendWsMessage({type:"update_conversation_settings",conversationId:t,...s})}function rd(e,t,s){let n=e.currentConversation;if(!n)return;let r=e.conversationMcpServers[n];if(r){let f=r.find(p=>p.name===t);f&&(f.enabled=s)}let i=e.conversationMcpServers[n]||[],o=e.conversationMcpServerTools[n]||{},a=[];for(let f of i)if(!f.enabled){let p=o[f.name];p&&p.length>0?a.push(...p):a.push(`mcp__${f.name}`)}let u=[...(e.conversations.find(f=>f.id===n)?.disallowedTools||[]).filter(f=>!f.startsWith("mcp__")),...a];qo(e,n,{disallowedTools:u})}function id(e,t,s){return t?e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}}):!1}function od(e,t,s){e._recentlyDeletedSessions||(e._recentlyDeletedSessions={}),e._recentlyDeletedSessions[t]=Date.now(),e.conversations=e.conversations.filter(i=>i.id!==t);let n=e.activeConversations.indexOf(t);n>=0&&(e.activeConversations.splice(n,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null));for(let i of e.panels)i.conversationId===t&&(i.conversationId=null);let r=e.pinnedSessions.indexOf(t);r>=0&&(e.pinnedSessions.splice(r,1),localStorage.setItem("pinned-sessions",JSON.stringify(e.pinnedSessions))),e.sendWsMessage({type:"delete_conversation",requestId:`delete_${crypto.randomUUID()}`,conversationId:t,...s?{agentId:s}:{}})}function ad(e,t,s=[],n={}){let r=n.expertSelections&&n.expertSelections.length>0;if(!t.trim()&&s.length===0&&!r||!e.currentAgent||!e.currentConversation)return;let i=Jc();if(e.addMessage({type:"user",content:t,clientMessageId:i,attachments:s.length>0?s:void 0,expertSelections:r?n.expertSelections:void 0}),t.trim()){let c=t.trim().substring(0,100);e.conversationTitles[e.currentConversation]=c}else if(r){let c=n.expertSelections[0],d=`@${c.role}${c.action?"\xB7"+c.action:""}`;e.conversationTitles[e.currentConversation]=d}let o=e.conversations.find(c=>c.id===e.currentConversation);o&&(o.lastMessageAt=Date.now()),e.processingConversations[e.currentConversation]||(e.processingConversations[e.currentConversation]=!0,e._closedAt?.[e.currentConversation]&&delete e._closedAt[e.currentConversation],e._turnCompletedConvs?.delete(e.currentConversation),e.getOrCreateExecutionStatus(e.currentConversation),Ls(e,e.currentConversation));let a=s.map(c=>c.fileId),l={type:"chat",conversationId:e.currentConversation,prompt:t,fileIds:a,workDir:e.currentWorkDir,clientMessageId:i};if(n.targetRole&&(l.targetRole=n.targetRole),r){l.expertSelections=n.expertSelections;let c=Ho(n.expertSelections,e.customExpertRoles,t,e.language||"zh-CN");c&&(l.expertMessage=c.effectivePrompt)}e.sendWsMessage(l)||bn(e).then(()=>{e.sendWsMessage(l)}).catch(()=>{e.addMessage({type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[e.currentConversation],Ae(e,e.currentConversation)})}function ld(e){if(!e.currentConversation||!e.processingConversations[e.currentConversation])return;let t=e.currentConversation;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Bt(e,t),e.addMessage({type:"system",content:Ee("chat.execution.cancelled")})}function cd(e,t,s,n){let r=n||e.currentConversation,o=(e.messagesMap[r]||[]).find(g=>g.type==="tool-use"&&g.toolName==="AskUserQuestion"&&g.askRequestId===t),a=e.currentView==="yeaft"||!!o?.sessionId;if(a&&o?.askPending)return;let l=o?.sessionId||e.yeaftActiveSessionFilter||null,c=typeof o?.agentId=="string"&&o.agentId?o.agentId:null,d=a?fh(e,r):[],u=d.length===1?d[0]:null;if(c&&u&&c!==u)return!1;let f=a&&!c&&!u&&typeof e.agentIdForSession=="function"?e.agentIdForSession(l):null,p=e.sendWsMessage(a?{type:"yeaft_ask_user_answer",agentId:c||u||f||e.yeaftAgentId||e.currentAgent||null,conversationId:r,requestId:t,toolCallId:o?.toolId||null,answers:s,sessionId:l,vpId:o?.vpId||o?.speakerVpId||null,turnId:o?.turnId||null,threadId:o?.threadId||"main"}:{type:"ask_user_answer",conversationId:r,requestId:t,answers:s});if(o&&!a)o.askAnswered=!0,o.selectedAnswers=s;else if(o&&p!==!1){let g=++ph;o.askPending=!0,o.pendingAnswers=s,o.askSubmitGeneration=g;let b=setTimeout(()=>{o.askSubmitGeneration!==g||o.askPending!==!0||(o.askPending=!1,o.pendingAnswers=null,o.askSubmitGeneration=null)},uh);typeof b?.unref=="function"&&b.unref()}p!==!1&&r&&!e.processingConversations[r]&&(e.processingConversations[r]=!0,e._closedAt?.[r]&&delete e._closedAt[r],e.getOrCreateExecutionStatus(r))}function dd(e,t){t&&(e.activeConversations.includes(t)||e.activeConversations.length>=3||(e.activeConversations.push(t),e.messagesMap[t]||(e.messagesMap[t]=[],e.requestChatHistory?.(t,{mode:"recent",turns:5})),Es(e)))}function ud(e,t){let s=e.activeConversations.indexOf(t);s<0||(e.activeConversations.splice(s,1),e.activeConversations.length===0&&(localStorage.removeItem("lastViewedConversation"),e.lastViewedConversation=null),Es(e))}function pd(e,t,s,n=[],r={}){let i=r.expertSelections&&r.expertSelections.length>0;if(!s.trim()&&n.length===0&&!i||!e.currentAgent||!t)return;let o=Jc();if(e.addMessageToConversation(t,{type:"user",content:s,clientMessageId:o,attachments:n.length>0?n:void 0,expertSelections:i?r.expertSelections:void 0}),s.trim()){let d=s.trim().substring(0,100);e.conversationTitles[t]=d}else if(i){let d=r.expertSelections[0],u=`@${d.role}${d.action?"\xB7"+d.action:""}`;e.conversationTitles[t]=u}let a=e.conversations.find(d=>d.id===t);a&&(a.lastMessageAt=Date.now()),e.processingConversations[t]||(e.processingConversations[t]=!0,e._closedAt?.[t]&&delete e._closedAt[t],e._turnCompletedConvs?.delete(t),e.getOrCreateExecutionStatus(t),Ls(e,t));let l=n.map(d=>d.fileId),c={type:"chat",conversationId:t,prompt:s,fileIds:l,workDir:a?.workDir||e.currentWorkDir,clientMessageId:o};if(r.targetRole&&(c.targetRole=r.targetRole),i){c.expertSelections=r.expertSelections;let d=Ho(r.expertSelections,e.customExpertRoles,s,e.language||"zh-CN");d&&(c.expertMessage=d.effectivePrompt)}e.sendWsMessage(c)||bn(e).then(()=>{e.sendWsMessage(c)}).catch(()=>{e.addMessageToConversation(t,{type:"system",content:Ee("chat.connection.reconnectFailed")}),delete e.processingConversations[t],Ae(e,t)})}function fd(e,t){if(!t||!e.processingConversations[t])return;e.sendWsMessage({type:"cancel_execution",conversationId:t}),delete e.processingConversations[t],Ae(e,t),e._closedAt||(e._closedAt={}),e._closedAt[t]=Date.now();let s=e.executionStatusMap[t];s&&(s.currentTool=null),e.finishStreamingForConversation(t),Bt(e,t),e.addMessageToConversation(t,{type:"system",content:Ee("chat.execution.cancelled")})}function gd(e){e.ws&&e.ws.readyState===WebSocket.OPEN&&(typeof e.requestYeaftSessionInventory=="function"?e.requestYeaftSessionInventory():e.sendWsMessage({type:"get_agents"}))}function md(e){!e.currentAgent||!e.currentConversation||e.sendWsMessage({type:"refresh_conversation",conversationId:e.currentConversation})}function hd(e,t){t&&e.sendWsMessage({type:"restart_agent",agentId:t})}function vd(e,t){t&&e.sendWsMessage({type:"upgrade_agent",agentId:t})}var uh,ph,yd=F(()=>{Nt();ss();po();Rr();Ds();xt();_n();uh=1e4,ph=0});function mh(e=globalThis.localStorage){try{return e?.getItem(wd)==="yeaft"?"yeaft":bd}catch{return bd}}function No(e,t=globalThis.localStorage){if(e!=="chat"&&e!=="yeaft")return!1;try{return t?.setItem(wd,e),!!t}catch{return!1}}function kd(e=globalThis.localStorage){let t=mh(e);if(t!=="yeaft")return{currentView:t,_yeaftTransitionActive:!1,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:null};let s=null;try{s=e?.getItem("lastViewedConversation")||null}catch{}let n=s&&!s.startsWith("yeaft-")?s:null;return{currentView:t,_yeaftTransitionActive:!0,_savedActiveConversations:null,_savedChatIdentity:null,_pendingChatRestoreConversationId:n}}function Bo(e){return e._yeaftTransitionActive?!1:(e._savedActiveConversations=[...e.activeConversations],e._savedChatIdentity={agentId:e.currentAgent||null,agentInfo:e.currentAgentInfo?{...e.currentAgentInfo}:null,workDir:e.currentWorkDir||null},e._yeaftTransitionActive=!0,!0)}function Sd(e){let t=Bo(e);return e.activeConversations=[e.yeaftConversationId],t}function Id(e){if(!e._yeaftTransitionActive)return null;let t=e._savedChatIdentity||null;return e.activeConversations=e._savedActiveConversations||[],t&&(e.currentAgent=t.agentId,e.currentAgentInfo=t.agentInfo,e.currentWorkDir=t.workDir),e._savedActiveConversations=null,e._savedChatIdentity=null,e._yeaftTransitionActive=!1,t}var wd,bd,Cd=F(()=>{wd="yeaft-preferred-conversation-view",bd="chat"});function Ad(e,t,s){let n={...e||{}},r={...n[t]||{}};return r[s]=(r[s]||0)+1,n[t]=r,n}function xd(e,t,s){let n={...e||{}},r={...n[t]||{}},i=(r[s]||0)-1;return i<=0?delete r[s]:r[s]=i,Object.keys(r).length===0?delete n[t]:n[t]=r,n}var Td=F(()=>{});function Wo(e){return e.currentView==="yeaft"?e.yeaftConversationId||null:e.activeConversations[0]||null}var Md=F(()=>{});function Pd({loops:e,turnsById:t,turnOrder:s,maxLoops:n}){if(!Array.isArray(e)||e.length<=n)return{loops:e,turnsById:t,turnOrder:s};let r=e.length-n,i=e.slice(r),o=new Set;for(let c of i)c&&c.turnId&&o.add(c.turnId);for(let c of s){let d=t[c];d&&d.closedAt==null&&o.add(c)}let a={};for(let c of Object.keys(t))o.has(c)&&(a[c]=t[c]);let l=s.filter(c=>o.has(c));return{loops:i,turnsById:a,turnOrder:l}}var Rd=F(()=>{});function Re(e){let t=Number(e);return Number.isFinite(t)?t:null}function Hs(e){let t=Re(e);return Number.isInteger(t)&&t>0?t:null}function Uo(e){let t=Re(e);return Number.isInteger(t)&&t>=0?t:null}function _d(e){return yh.has(e)?1:0}function bh(e,t){if(!e)return t||null;if(!t)return e;let s=Re(e.progressRevision),n=Re(t.progressRevision);if(s!=null||n!=null){if(s==null)return t;if(n==null)return e;if(s!==n)return n>s?t:e}let r=_d(e.status),i=_d(t.status);if(r!==i)return i>r?t:e;let o=Re(e.updatedAt)??Re(e.createdAt)??0;return(Re(t.updatedAt)??Re(t.createdAt)??0)>o?t:e}function Os(e){return Math.max(0,Number(e)||0)}function Ed(e){return typeof e?.id=="string"&&e.id.startsWith("event:")?e.id.slice(6):null}function wh(e,t){if(/^\d+$/.test(e)&&/^\d+$/.test(t)){let s=BigInt(e),n=BigInt(t);return s<n?-1:s>n?1:0}return e.localeCompare(t)}function kh(e,t){let s=Os(e?.createdAt)-Os(t?.createdAt);if(s)return s;let n=Ed(e),r=Ed(t);if(n!=null&&r!=null)return wh(n,r);let i=e?.role==="user"?0:1,o=t?.role==="user"?0:1;if(i!==o)return i-o;let a=Os(e?.generation)-Os(t?.generation);return a||Os(e?.attempt)-Os(t?.attempt)||String(e?.id||"").localeCompare(String(t?.id||""))}function En(...e){let t=new Map;for(let s of e){let n=Array.isArray(s)?s:[s];for(let r of n)r?.id&&t.set(r.id,bh(t.get(r.id),r))}return[...t.values()].sort(kh)}function tt(e){let t=Number(e);return Number.isInteger(t)&&t>0?t:1}function qs(e,t,s,n){return`${e}:${t}:${s}:${tt(n)}`}function Dn(e,t,s,n){return`${e}:${t}:${s}:${tt(n)}`}function Ns(e,t){if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);if(s!=null&&n!=null&&s!==n)return s<n;let r=Re(e.coordinatorRevision),i=Re(t.coordinatorRevision);if(r!=null&&i!=null&&r!==i)return r<i;let o=Re(e.updatedAt),a=Re(t.updatedAt);return o!=null&&a!=null&&o<a}function Dd(e,t){if(Ns(e,t))return!0;if(!e||!t||e.id!==t.id)return!1;let s=Re(e.revision),n=Re(t.revision);return e.currentActionId!==t.currentActionId&&s!=null&&n!=null&&s<=n}function jo(e,t){let s=Hs(e?.generation),n=Hs(t?.generation);if(s!=null&&n!=null&&s!==n)return n<s;let r=Uo(e?.attempt),i=Uo(t?.attempt);if(r!=null&&i!=null&&r!==i)return i<r;let o=Re(e?.progressRevision),a=Re(t?.progressRevision);return o!=null&&a!=null&&a<o}function zo(e,t){if(!e||e.id!==t?.id||Ns(t,e))return null;let s=Array.isArray(e.actions)?e.actions:[],n=Array.isArray(t.actionStats)?t.actionStats:[],r=e.currentActionId||null,i=Object.prototype.hasOwnProperty.call(t,"currentActionId")?t.currentActionId||null:r,o=typeof t.eventActionId=="string"&&n.some(g=>g?.id===t.eventActionId)?t.eventActionId:null,a=o||r!==i&&r||i;if(!a)return null;let l=s.find(g=>g?.id===a)||null,c=n.find(g=>g?.id===a)||(t.currentAction?.id===a?t.currentAction:null);if(l&&c&&jo(l,c))return null;let d=Hs(l?.generation),u=Hs(c?.generation),f=Uo(c?.attempt),p={actionId:a,generation:u||d||1,...f==null?{}:{attempt:f}};return o||r!==i||!l||d!=null&&u!=null&&u>d||l?.status==="running"&&c?.status&&c.status!=="running"?p:null}function Ld(e,t){if(!e||e.id!==t?.id||Ns(t,e))return!1;let s=Re(t.coordinatorRevision),n=Re(e.coordinatorRevision)??0;return s!=null&&s>n?!0:zo(e,t)!=null}function $d(e,t){if(!e||e.id!==t?.id||Ns(t,e))return e;let s={...e},n=!Array.isArray(e.actions)||!Array.isArray(t.actionStats);if(Array.isArray(e.actions)&&Array.isArray(t.actionStats)){let r=new Map(t.actionStats.map(o=>[o?.id,o])),i=!1;n=!0,s.actions=e.actions.map(o=>{let a=r.get(o?.id);if(!a)return o;if(i=!0,jo(o,a))return n=!1,o;if(Re(a?.progressRevision)==null){let{response:u,messages:f,...p}=a;return{...o,...p}}let c=Hs(o?.generation),d=Hs(a?.generation);if(c!=null&&d!=null&&d>c){let{messages:u,thread:f,liveMessage:p,response:g,failure:b,messageCursor:h,messageCount:A,failureReason:w,...S}=o;return{...S,...a}}return{...o,...a}}),i||(n=!1)}for(let r of vh)!n&&Sh.has(r)||Object.prototype.hasOwnProperty.call(t,r)&&(s[r]=t[r]);return s}function Vd(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let s=new Map(e.map(n=>[n?.id,n]));return t.some(n=>{let r=s.get(n?.id);return r?jo(r,n):!1})}function Fd(e,t){return Re(e?.revision)===Re(t?.revision)&&Re(e?.coordinatorRevision)===Re(t?.coordinatorRevision)&&Re(e?.updatedAt)===Re(t?.updatedAt)}function Od(e,t){return!e||!t||e.id!==t.id?!1:Ns(e,t)?!0:Fd(t,e)&&Vd(t.actions,e.actions)}function Er(e,t){let s=Array.isArray(e)?e:[],n=s.find(i=>i.id===t?.id)||null,r=n&&Ns(t,n)?n:t;return n&&r===t&&Fd(n,t)&&Vd(n.actionStats,t.actionStats)&&(r=n),r?.id?[r,...s.filter(i=>i.id!==r.id)].sort((i,o)=>Number(o.updatedAt||0)-Number(i.updatedAt||0)):s}var vh,yh,Sh,Ko=F(()=>{vh=Object.freeze(["revision","planRevision","ledgerRevision","coordinatorRevision","title","goal","workItemType","planningMode","status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason","origin","linkedSessionIds","createdAt","updatedAt"]);yh=new Set(["completed","failed","cancelled","superseded","interrupted"]);Sh=new Set(["status","lifecycle","attentionState","activeActionIds","attentionActionIds","currentActionId","currentAction","executionStats","failureReason"])});function ls(e){return typeof e=="string"?e.trim():""}function Hd(e){if(typeof e=="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e=="string"&&e.trim()){let t=Date.parse(e);if(Number.isFinite(t))return t}return null}function vt(e){let t=Hd(e);if(!t)return"";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(t))}catch{return""}}function Ih(e){return Array.isArray(e)?e.slice(0,100).map(t=>({content:ls(t?.content).slice(0,2e3),status:["pending","in_progress","completed"].includes(t?.status)?t.status:"pending",...ls(t?.activeForm)?{activeForm:ls(t.activeForm).slice(0,2e3)}:{}})).filter(t=>t.content):[]}function Dr(e){if(!e||typeof e!="object")return null;let t=ls(e.content).slice(0,1e5),s=Ih(e.todos);if(!t&&s.length===0)return null;let n=e.role==="assistant"?"assistant":"user",r=Hd(e.timestamp);return{id:ls(e.id).slice(0,256)||null,role:n,author:ls(e.author).slice(0,256)||(n==="assistant"?"Assistant":"User"),content:t,...r?{timestamp:r}:{},...s.length>0?{todos:s}:{}}}function qd(e,t){return Dr({id:e?.messageId||e?.id||null,role:"user",author:t,content:e?.content||"",timestamp:e?.timestamp||e?.createdAt||e?.ts||e?.time||null})}function Nd(e,t){let s=e?.todoMsg?.toolInput?.todos,n=Array.isArray(e?.toolMsgs)?e.toolMsgs.map(o=>ls(o?.toolName)).filter(Boolean):[],r=Number(e?.toolSummaryCount||0)||0,i=n.length>0?`Tool actions: ${n.join(", ")}`:r>0?`Tool actions: ${r}`:"";return Dr({id:e?.atMessageId||e?.messageId||e?.id||e?.turnId||null,role:"assistant",author:t,content:e?.textContent||i,timestamp:e?.timestamp||e?.createdAt||e?.speakerTimestamp||null,todos:s})}var cs=F(()=>{});function Bd(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:t?.type==="text"&&typeof t.text=="string"?t.text:"").join(""):e==null?"":String(e)}function Ch(e,t){if(!e||e.type!=="assistant")return!1;let s=e.sessionId??e.groupId??null,n=e.speakerVpId||e.vpId||null;return!(t.sessionId&&s!==t.sessionId||t.vpId&&n!==t.vpId||t.turnId&&e.turnId!==t.turnId)}function Wd(e,t={}){if(!Array.isArray(e)||!t.turnId)return!1;let s=e.filter(n=>Ch(n,t));if(s.length===0)return!1;for(let n of s)n.responseKind="progress";if(t.reason==="end_turn"){for(let n=s.length-1;n>=0;n-=1)if(Bd(s[n].content).trim()){s[n].responseKind="result";break}}return!0}function Lr(e,t){if(!e||!t)return;let s=Bd(t.content);s&&(Array.isArray(e.textSegments)||(e.textSegments=[]),e.textSegments.push({key:t.messageId||t.id||`response-${e.textSegments.length}`,content:s,kind:t.responseKind==="result"?"result":"progress",explicitKind:t.responseKind==="progress"||t.responseKind==="result",isStreaming:t.isStreaming===!0}),e.textContent=e.textSegments.map(n=>n.content).join(`
|
|
7
7
|
|
|
8
|
-
`))}function $r(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||Yo.has(l?.status)||Yo.has(l?.turnEndReason)||Yo.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 Yo,Vr=F(()=>{Yo=new Set(["aborted","errored","error","cancelled","canceled"])});function Go(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Qo(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 Xo(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 Ud(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(Go(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Qo(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Xo(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 jd(e,t){return t?e&&(e.sessionId??e.groupId)===t:!0}function Zo(e=[],t=null,s=5){let n=Math.max(1,Number.isFinite(s)?Math.floor(s):5),r=[],i=[],o=null,a=c=>{o&&(i.push({start:o.start,end:c,kind:o.kind}),o=null)};for(let c of e){if(!jd(c,t))continue;let d=r.length;if(r.push(c),Go(c)||c.type==="system"||c.type==="error"){a(d),o={start:d,kind:c.type};continue}if(!Qo(c)){o||(o={start:d,kind:"other"});continue}(!o||o.kind==="assistant"&&Xo(o,c))&&(a(d),o={start:d,kind:"assistant",turnId:c.turnId||"",speakerVpId:c.speakerVpId||c.vpId||""}),o.lastTurnId=c.turnId||o.lastTurnId||"",o.speakerVpId=o.speakerVpId||c.speakerVpId||c.vpId||""}if(a(r.length),i.length<=n)return r;let l=i[i.length-n];return r.slice(l.start)}function zd(e=[],t=null,s=5){let n=Math.max(1,s||5),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(jd(a,t)){if(Go(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Qo(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Xo(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 cs(){return 5}function Ln(){return 20}var Kd=F(()=>{});function xh(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=us();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function au(e,t){let s=xh(e,t);return s.size===1?s.values().next().value:null}function qr(e,t,s){return!!s&&au(e,t)===s}function pt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Yd(e,t,s=null){if(!t)return!1;let n=s||Ie(e,t),r=dt(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&qr(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(pt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(pt(i,t,n)&&Nr.has(i?.state))return!0;return!1}function Th(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=Fo(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==dt(t,n):!o.startsWith(i))),n)qr(e,n,t)&&delete r[n];else for(let o of Object.keys(r))qr(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||!Nr.has(i?.state))continue;let a=dt(t,o)||o;r[a]=!0}return r}function Bs(e,t,s){let n=Oo(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 Gd(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=Fo(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function Tt(e,t){return`${e||""}:${t||""}`}function Eh(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 Dh(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 Lh(e={}){return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Eh(e.target),text:String(e.text||""),attachments:Array.isArray(e.attachments)?e.attachments.map(t=>({fileId:t?.fileId||"",name:t?.name||"",mimeType:t?.mimeType||"",size:Math.max(0,Number(t?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function Xd(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 Zd(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 $h(e,t){return ra.every(s=>!t[s]||e[s]===t[s])}function lu(e,t){return ra.every(s=>!e[s]||!t[s]||e[s]===t[s])}function Jd(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=>$h(Zd(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>lu(Zd(o,s),t));return i.length===1?i[0]:null}function cu(e){return ra.map(t=>e[t]||"").join("\0")}function Vh(e,t,s){let n=cu(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>Qd){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-Qd))delete r[o]}e._yeaftAskTerminalEvents=r}function eu(e,t){let s=e._yeaftAskTerminalEvents||{},n=cu(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>lu(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 Fh(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function Jo(e,t){t.type==="ask_user_answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers||{},e.askExpired=!1):(e.isHistory=!0,e.askExpired=!0,e.askAnswered=!1,e.selectedAnswers=null),e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askRequestId=null}function Oh(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 Hh(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 $n(e){return e?.role==="assistant"&&e?.turnId?`response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:e?.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function tu(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function ea(e,t,s){return`${dt(e,t)}::${s||""}`}function ta(e){let t=Object.entries(e||{}),s=t.filter(([,r])=>r?.status==="running"),n=t.filter(([,r])=>r&&r.status!=="running"&&na.has(r.status)).sort((r,i)=>tu(i[1])-tu(r[1])).slice(0,Ph);return Object.fromEntries([...s,...n])}function us(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function Ie(e,t,s=null){if(s)return s;if(t){let n=us(),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 qh(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 su(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"&&qh(n?.version||r?.version,"1.0.166")}function ds(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=us();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function Hr(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=ds(e);return s||(us()?.sessions?.grp_default?"grp_default":null)}function Wt(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function Mt(e,t=null){let s=t||e?.yeaftActiveSessionFilter||null,n=Ie(e,s);return(n&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[n]:null)||e?.yeaftConversationId||null}function nu(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=Ie(e,n);return!r||!s||r===s}var Ah,Fe,Fr,Or,Mh,Ph,na,Nr,Rh,_h,Qd,ra,ru,sa,iu,ou,ps,Br=F(()=>{ct();ao();xt();po();Ds();Vc();Kc();yd();ts();Nt();Cd();Co();Sr();Td();Md();Rd();co();Ko();To();ls();Vr();Tr();_o();Rn();Kd();({defineStore:Ah}=Pinia),Fe=Object.freeze([]),Fr=(e,t,s)=>`${e||""}::${t||""}::${s}`;Or=5,Mh=15e3,Ph=8,na=new Set(["succeeded","failed","cancelled","orphaned"]),Nr=new Set(["typing","thinking","retrying","streaming","tool"]),Rh=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),_h=8,Qd=64;ra=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);ru=1e3,sa=1,iu=5,ou=200,ps=Ah("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},chatSessionState:{},panels:[],activePanelId:null,_pendingPaneId:null,conversationTitles:{},customConversationTitles:{},processingConversations:{},yeaftProcessingSessions:{},yeaftUnreadSessionKeys:{},theme:localStorage.getItem("theme")||(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),themeFollowSystem:!localStorage.getItem("theme"),locale:localStorage.getItem("locale")||"zh-CN",executionStatusMap:{},sessionHealth:{},historySessions:[],historySessionsLoading:!1,folders:[],foldersLoading:!1,providerModels:[],providerModelsLoading:!1,contextUsage:null,lastUsedAgent:localStorage.getItem("lastUsedAgent")||null,lastUsedSession:JSON.parse(localStorage.getItem("lastUsedSession")||"null"),lastViewedConversation:localStorage.getItem("lastViewedConversation")||null,pendingRecovery:null,recoveryDismissed:!1,sessionLoading:!1,sessionLoadingText:"",agentSwitching:!1,pendingAgentSelection:null,_pendingSessionTitle:null,workbenchExpanded:!1,workbenchMaximized:!1,sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_yeaftReconnectCatchUpPending:!1,_yeaftOpenedSessionsLoadedAgents:{},_yeaftAgentSeen:null,slashCommandsMap:{},slashCommandDescriptions:{},inputDrafts:{},mcpServers:{},expertRoleDefinitions:null,llmConfig:{},llmModelDiscovery:{},llmGithubDevice:null,modelsDevRegistry:{registry:{},fetchedAt:0,error:null,loaded:!1},_modelsDevPending:null,yeaftSettings:{},searchSettings:null,tavilyUsage:null,tavilyUsageLoading:!1,_perfTraceQueue:[],_perfTraceFlushTimer:null,yeaftPerfTraceByMessageId:{},yeaftPerfTraceByTurnId:{},yeaftMcpServers:[],yeaftMcpRuntime:{connected:!1,toolCount:0,perServer:[]},yeaftMcpLoading:!1,yeaftMcpError:null,btwMode:!1,btwMessages:[],btwLoading:!1,btwSessionId:null,conversationMcpServers:{},conversationMcpServerTools:{},mcpPanelOpen:!1,expertSelections:[],customExpertRoles:[],subagents:{},activeSubagentId:null,activeRightPanel:null,pinnedSessions:JSON.parse(localStorage.getItem("pinned-sessions")||"[]"),...kd(),workCenterOpen:!1,workCenterAgentId:null,workCenterItemsByAgent:{},workCenterListPageByAgent:{},workCenterListMoreLoadingByAgent:{},_workCenterListGenerationByAgent:{},_workCenterListQueryByAgent:{},_workCenterListFiltersByAgent:{},_workCenterListMoreRequestsByAgent:{},_workCenterListEventGenerationByAgent:{},_workCenterListEventsByAgent:{},_workCenterDeletedIdsByAgent:{},workCenterDetailByAgent:{},workCenterActionMessages:{},workCenterActionMessagesLoading:{},workCenterActionMessagesError:{},workCenterActionRequests:{},workCenterActionRequestDetails:{},workCenterActionRequestsLoading:{},workCenterActionRequestsError:{},workCenterActionRequestDetailsLoading:{},workCenterActionRequestDetailsError:{},workCenterLoadedByAgent:{},workCenterLoadingByAgent:{},workCenterErrorByAgent:{},workCenterWatcherByAgent:{},workCenterSettingsByAgent:{},workCenterRuntimeByAgent:{},workCenterSettingsLoadingByAgent:{},workCenterSettingsErrorByAgent:{},_workCenterSettingsGenerationByAgent:{},_workCenterDetailRequestGenerationByAgent:{},_workCenterDetailEventRefreshByAgent:{},_workCenterActionInputGenerationByAgent:{},_workCenterActionMessageRequests:{},_workCenterActionMessageGenerationByKey:{},_workCenterActionRequestsGeneration:{},_workCenterActionRequestDetailsGeneration:{},workCenterPending:{},workCenterComposerDrafts:{},workCenterMessageOutbox:{},_workCenterBrowserFence:null,_workCenterBrowserUnsubscribe:null,workCenterCreateDraft:null,yeaftConversationId:null,yeaftConversationIdsByAgent:{},_yeaftPendingConversationPromotions:{},_yeaftRetiredConversationIdsByAgent:{},_yeaftRetiredConversationTargetsByAgent:{},yeaftSessionAgentById:{},yeaftModel:null,yeaftModelEffort:null,yeaftSessionReady:!1,yeaftStatus:null,yeaftAvailableModels:[],yeaftStatusByAgent:{},_yeaftRetiredCatalogEpochsByAgent:{},yeaftModelsRefreshing:!1,yeaftModelRefreshError:null,yeaftYeaftDir:null,yeaftActiveTasksBySession:{},yeaftStoppingTasksById:{},yeaftToolStats:null,yeaftToolStatsLoading:!1,yeaftDebugLoops:[],yeaftDebugTurnsById:{},yeaftDebugTurnOrder:[],yeaftDebugHistoryLoading:!1,yeaftDebugHistoryError:null,yeaftDebugHistoryFetchedAt:0,yeaftDebugHistoryLimit:sa,yeaftDebugHistoryHasMore:!1,yeaftDebugSearch:"",yeaftDebugSessionFilter:null,yeaftDreamLatest:{},yeaftDreamSnapshots:{},yeaftDreamPromptLoads:{},yeaftDreamEvents:{},yeaftReflectionCards:{},yeaftSubAgentCards:{},yeaftSidebarV2Enabled:!0,yeaftActiveSessionFilter:null,_currentYeaftSessionId:null,_currentYeaftVpId:null,_currentYeaftTurnId:null,_currentYeaftThreadId:null,_yeaftAskTerminalEvents:{},activeVpTurns:{},vpStatuses:{},stoppingVpTurnIds:{},yeaftVpTyping:{},_vpCrudPending:null}),getters:{currentConversation:e=>e.activeConversations[0]||null,activeConversationId:e=>Wo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=ds(e);return n?{runtimeProvider:"yeaft",agentId:Ie(e,n),sessionId:n}:null}let t=Wo(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]||Fe;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||cs();return Zo(s,e.yeaftActiveSessionFilter||null,r)}return s},yeaftAllMessages:e=>{let t=Mt(e);return t&&e.messagesMap[t]||Fe},yeaftVisibleMessages(e){let t=Mt(e),s=t&&e.messagesMap[t]||Fe,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||cs();return Zo(s,e.yeaftActiveSessionFilter||null,r)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=Mt(e),s=t&&e.messagesMap[t]||Fe,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||cs();return zd(s,e.yeaftActiveSessionFilter||null,r)},activeYeaftHistoryState(e){return Ro(e)},yeaftInitialHistoryLoading(e){let t=Ro(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return Fe;let s=(e.yeaftVpTyping||{})[t];if(!s)return Fe;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?Fe: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=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=Hr(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||Fe,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||Fe,r=e.yeaftReflectionCards||{},i=e.yeaftDebugSessionFilter,o;i==="__all__"?o=null:i?o=i:o=null;let a={};for(let d of n)!d||!d.turnId||(a[d.turnId]||(a[d.turnId]=[]),a[d.turnId].push(d));let l={};for(let d of Object.keys(r)){let u=r[d];!u||!u.turnId||(l[u.turnId]||(l[u.turnId]=[]),l[u.turnId].push(u))}let c=[];for(let d=t.length-1;d>=0;d--){let u=t[d],f=s[u];if(!f||o&&f.sessionId&&f.sessionId!==o)continue;let p=a[u]||Fe,g=l[u]||Fe,b=p.length,h=0,A=0;for(let y of p){let m=y&&y.usage;m&&Number.isFinite(m.totalTokens)?h+=m.totalTokens:m&&(h+=(m.totalInputTokens||(m.inputTokens||0)+(m.cacheReadTokens||0)+(m.cacheWriteTokens||0))+(m.outputTokens||0)),y&&Number.isFinite(y.latencyMs)&&(A+=y.latencyMs)}let w=!f.closedAt,S={...f,loopCount:w||!f.loopCount?b:f.loopCount,totalTokens:w||!f.totalTokens?h:f.totalTokens,totalMs:w||!f.totalMs?A:f.totalMs,loops:p,reflections:g};c.push(S)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||Fe){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||Fe).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=ds(e);return t?Yd(e,t,Ie(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"?us()?.activeSession?.workDir||e.yeaftYeaftDir||e.currentAgentInfo?.workDir||"":e.currentWorkDir||e.currentAgentInfo?.workDir||"",currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),getConversationTitle:e=>t=>e.customConversationTitles[t]||e.conversationTitles[t]||null,executionStatus:e=>e.currentConversation?e.executionStatusMap[e.currentConversation]||{currentTool:null,toolHistory:[],lastActivity:null}:{currentTool:null,toolHistory:[],lastActivity:null},isConversationProcessing:e=>t=>!!e.processingConversations[t],isConversationConnecting:e=>t=>t?!!e.conversations.find(n=>n.id===t)?.connecting:!1,isConversationCompacting:e=>t=>t?e.compactStatus?.conversationId===t&&e.compactStatus?.status==="compacting":!1,isYeaftSessionProcessing:e=>(t,s=null)=>Yd(e,t,s),isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=Ie(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[yr(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return Fe;let t=e.subagents[e.currentConversation];return t?Object.values(t):Fe},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 Fe;let t=e.subagents[e.currentConversation];if(!t)return Fe;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:Fe).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||Fe},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&&No("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),Id(this),t&&s&&n&&(this.autoRestoreConversation(t),this.sendWsMessage({type:"refresh_conversation",conversationId:t}))},enterWorkCenter(e=null){if(!this.hydrateWorkCenterBrowserState())return!1;let t=this.agents.filter(n=>n?.online&&Array.isArray(n.capabilities)&&n.capabilities.includes("work_center")),s=t.some(n=>n.id===e)?e:t[0]?.id||null;if(!s)return this.workCenterOpen=!1,this.workCenterAgentId=null,!1;if(this.currentAgent!==s){this.selectAgent(s),this.currentAgent=s;let n=this.agents.find(r=>r.id===s);n&&(this.currentAgentInfo=n)}return this.workCenterAgentId=s,this.workCenterOpen=!0,this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){this.workCenterOpen=!1},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||Ie(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=Al(()=>{gn(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=hr();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!gn(this._workCenterBrowserFence)){let t=Cl(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 Tt(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=Tt(e,t);if(!e||!t)return;let r={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),attachments:Array.isArray(s.attachments)?s.attachments:[],target:Dh(s.target),error:String(s.error||"")}};return oo(r,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=r,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[Tt(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=Tt(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],oo(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Lh(e),s=Tt(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 mn(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[Tt(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=Tt(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 mn(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=Tt(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],mn(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=Tt(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],mn(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=Er(e,t),r=n.find(i=>i?.id===t?.id)||null;return!r||this.workItemMatchesBoardQuery(r,s)?n:n.filter(i=>i.id!==r.id)},async listWorkItems(e=null,t={}){let s=e||this.workCenterAgentId||this.currentAgent;if(!s)return[];let n={lane:["needs_attention","active","closed"].includes(t.lane)?t.lane:null,keyword:String(t.keyword||t.search||"").trim(),vpId:String(t.vpId||"").trim(),workItemType:String(t.workItemType||"").trim(),createdFrom:Number(t.createdFrom)||null,createdTo:Number(t.createdTo)||null,updatedFrom:Number(t.updatedFrom)||null,updatedTo:Number(t.updatedTo)||null,limit:Math.min(Math.max(Number(t.limit)||100,1),200)},r=JSON.stringify(n),i=Number(this._workCenterListGenerationByAgent[s]||0)+1,o=Number(this._workCenterListEventGenerationByAgent[s]||0);this._workCenterListGenerationByAgent={...this._workCenterListGenerationByAgent,[s]:i},this._workCenterListQueryByAgent={...this._workCenterListQueryByAgent,[s]:r},this._workCenterListFiltersByAgent={...this._workCenterListFiltersByAgent,[s]:n},this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!0},this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:null};try{let a=await this.workCenterRequest("list",n,s),l=(Array.isArray(a?.items)?a.items:[]).filter(d=>!this.workItemDeleted(s,d?.id));if(this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&this.workCenterAgentId===s){let d=l,u=this._workCenterListEventsByAgent[s]||{};for(let f of Object.values(u))Number(f?.generation)<=o||f?.queryKey!==r||(d=this.applyWorkItemBoardSummary(d,f.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:d},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[s]:{nextCursor:a?.nextCursor||null,queryKey:r}},this.workCenterWatcherByAgent={...this.workCenterWatcherByAgent,[s]:a?.watcher||null},this.workCenterLoadedByAgent={...this.workCenterLoadedByAgent,[s]:!0}}return l}catch(a){throw this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:a?.message||String(a)}),a}finally{this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!1})}},async loadMoreWorkItems(e=null){let t=e||this.workCenterAgentId||this.currentAgent,s=this.workCenterListPageByAgent[t],n=this._workCenterListFiltersByAgent[t];if(!t||!s?.nextCursor||!n)return[];let r=s.queryKey,i=this._workCenterListGenerationByAgent[t],o=Number(this._workCenterListEventGenerationByAgent[t]||0),a=s.nextCursor,l=`${i}:${r}:${a}`;if(this._workCenterListMoreRequestsByAgent[t]?.key===l)return this._workCenterListMoreRequestsByAgent[t].request;this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!0};let c=(async()=>{try{let d=await this.workCenterRequest("list",{...n,cursor:a},t),u=this.workCenterListPageByAgent[t];if(this._workCenterListGenerationByAgent[t]!==i||this._workCenterListQueryByAgent[t]!==r||u?.queryKey!==r||u?.nextCursor!==a||this.workCenterAgentId!==t)return[];let f=[...this.workCenterItemsByAgent[t]||[]];for(let g of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,g?.id))continue;let b=f.findIndex(h=>h.id===g.id);b<0?f.push(g):f[b]=Er([f[b]],g)[0]}let p=this._workCenterListEventsByAgent[t]||{};for(let g of Object.values(p))Number(g?.generation)<=o||g?.queryKey!==r||(f=this.applyWorkItemBoardSummary(f,g.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:f},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[t]:{nextCursor:d?.nextCursor||null,queryKey:r}},d?.items||[]}finally{if(this._workCenterListMoreRequestsByAgent[t]?.key===l){let d={...this._workCenterListMoreRequestsByAgent};delete d[t],this._workCenterListMoreRequestsByAgent=d,this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!1}}}})();return this._workCenterListMoreRequestsByAgent={...this._workCenterListMoreRequestsByAgent,[t]:{key:l,request:c}},c},workItemDeleted(e,t){return!!this._workCenterDeletedIdsByAgent[e]?.[t]},removeWorkItemState(e,t){this._workCenterDeletedIdsByAgent={...this._workCenterDeletedIdsByAgent,[e]:{...this._workCenterDeletedIdsByAgent[e]||{},[t]:!0}},this.beginWorkCenterDetailWrite(e),this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:(this.workCenterItemsByAgent[e]||[]).filter(n=>n.id!==t)},this.workCenterDetailByAgent[e]?.id===t&&(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:null});let s=`${e}:${t}:`;for(let n of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError","workCenterActionRequests","workCenterActionRequestsLoading","workCenterActionRequestsError","workCenterActionRequestDetails","workCenterActionRequestDetailsLoading","workCenterActionRequestDetailsError","_workCenterActionMessageRequests","_workCenterActionMessageGenerationByKey","_workCenterActionRequestsGeneration","_workCenterActionRequestDetailsGeneration"]){let r={};for(let[i,o]of Object.entries(this[n]||{}))i.startsWith(s)||(r[i]=o);this[n]=r}},beginWorkCenterDetailWrite(e){let t=Number(this._workCenterDetailRequestGenerationByAgent[e]||0)+1;return this._workCenterDetailRequestGenerationByAgent={...this._workCenterDetailRequestGenerationByAgent,[e]:t},t},commitWorkCenterDetail(e,t,s){if(t?.id&&this.workItemDeleted(e,t.id)||s!=null&&Number(this._workCenterDetailRequestGenerationByAgent[e]||0)!==s)return!1;let n=this.workCenterDetailByAgent[e];return n?.id===t?.id&&Od(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=tt(n),i=qs(e,t,s,r);this._workCenterActionMessageGenerationByKey={...this._workCenterActionMessageGenerationByKey,[i]:Number(this._workCenterActionMessageGenerationByKey[i]||0)+1};for(let a of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError"]){let l={...this[a]};delete l[i],this[a]=l}let o={...this._workCenterActionMessageRequests};for(let a of Object.keys(o))a.startsWith(`${i}:`)&&delete o[a];return this._workCenterActionMessageRequests=o,i},async loadWorkItemActionMessages(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=tt(s),a=qs(i,e,t,o),l=Number(this._workCenterActionMessageGenerationByKey[a]||0),c=`${a}:${n==null?"latest":String(n)}`;if(this._workCenterActionMessageRequests[c])return this._workCenterActionMessageRequests[c];this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:!0},this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:null};let d=(async()=>{try{let u=await this.workCenterRequest("get_action_messages",{id:e,actionId:t,generation:o,cursor:n,limit:20},i);if(this.workItemDeleted(i,e)||tt(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let f=this.workCenterActionMessages[a]?.messages||[],p=En(f,u?.messages||[]),g=this.workCenterActionMessages[a],b=g?.nextCursor,h=n==null?null:Number(n),A=b==null?null:Number(b),w=!g||h==null||A!=null&&h===A;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:w?u?.nextCursor??null:b,total:Math.max(Number(u?.total)||0,Number(g?.total)||0,p.length)}},u}catch(u){throw Number(this._workCenterActionMessageGenerationByKey[a]||0)===l&&(this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:u?.message||String(u)}),u}finally{if(this._workCenterActionMessageRequests[c]===d){let u={...this._workCenterActionMessageRequests};delete u[c],this._workCenterActionMessageRequests=u;let f=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:f}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=tt(s),o=Dn(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)&&tt(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=tt(s),c=`${Dn(o,e,t,a)}:${n}:${r}`,d=Number(this._workCenterActionRequestDetailsGeneration[c]||0)+1;this._workCenterActionRequestDetailsGeneration={...this._workCenterActionRequestDetailsGeneration,[c]:d},this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!0},this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:null};try{let u=await this.workCenterRequest("get_action_request",{id:e,actionId:t,generation:a,runId:n,requestId:r},o),f=!this.workItemDeleted(o,e)&&tt(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return f&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),f?u?.request||null:this.workCenterActionRequestDetails[c]||null}catch(u){throw this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:u?.message||String(u)}),u}finally{this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!1})}},async loadWorkCenterSettings(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("get_settings",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async refreshWorkCenterRuntime(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("refresh_runtime",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async saveWorkCenterSettings(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent;if(!s)throw new Error("No Agent selected");let n=Number(this._workCenterSettingsGenerationByAgent[s]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[s]:n};let r=await this.workCenterRequest("update_settings",{settings:e},s);return this._workCenterSettingsGenerationByAgent[s]===n&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[s]:r?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[s]:r?.runtime||null},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[s]:null}),r},previewWorkCenterPlan(e={},t=null){let s=t||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview",e,s)},async createWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("create",e,s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async updateWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("update",{id:e,patch:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async startWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("start",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async cancelWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("cancel",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async resumeWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("resume",{id:e,revision:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async deleteWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=await this.workCenterRequest("delete",{id:e,revision:t},n);return this.removeWorkItemState(n,e),r},async postWorkItemMessage(e,t,s,n,r=[],i=null,o={}){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let a=i||this.workCenterAgentId||this.currentAgent,l=this.prepareWorkCenterMessageEnvelope({agentId:a,workItemId:e,target:s,text:t,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!l)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let c=l.clientMessageId,d=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,u=await this.workCenterRequest("post_work_item_message",{id:l.workItemId,clientMessageId:c,text:l.text,target:l.target,revision:l.revision,planRevision:l.planRevision||Number(d?.planRevision)||0,ledgerRevision:l.ledgerRevision||Number(d?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(l.coordinatorRevision))?Number(l.coordinatorRevision):Number(d?.coordinatorRevision)||0,attachments:l.attachments},a);if(l.target.kind==="coordinator"){if(!u?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(a,e,c),u}return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.confirmWorkCenterMessageEnvelope(a,e,c),u},async sendWorkItemMessage(e,t,s,n=[],r=null,i={}){let o=r||this.workCenterAgentId||this.currentAgent,a=this.workCenterDetailByAgent[o]?.id===e?this.workCenterDetailByAgent[o]:null,l=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(a?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(a?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(a?.coordinatorRevision)||0,attachments:Array.isArray(n)?n:[]},o);if(!l?.accepted)throw new Error("Work Center Coordinator did not accept the message");return l},async retryWorkItemAction(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=this.beginWorkCenterDetailWrite(i),a=await this.workCenterRequest("retry_action",{id:e,actionId:t,revision:s,generation:n},i);return await this.listWorkItems(i,this._workCenterListFiltersByAgent[i]||{}),this.commitWorkCenterDetail(i,a,o),a},async sendWorkItemActionInput(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=Number(this._workCenterActionInputGenerationByAgent[a]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[a]:l};let c=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i},a);await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{});let d=this.workCenterDetailByAgent[a],u=d?.actions?.find(p=>p?.id===s),f=d?.id===e&&Number(d.revision)===Number(n)&&u&&Number(u.generation)===Number(r);return this._workCenterActionInputGenerationByAgent[a]===l&&f&&!Dd(c,d)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[a]:c},c):d?.id===e?d:c},async guideWorkItemAction(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=this.beginWorkCenterDetailWrite(a),c=await this.workCenterRequest("guide",{id:e,guidance:t,actionId:s,revision:n,generation:r,attachments:i},a);return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.commitWorkCenterDetail(a,c,l),c},previewWorkItemAttachment(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview_attachment",{id:e,attachmentId:t},n)},applyWorkCenterEvent(e,t){if(!e||!t?.workItem)return;let s=t.workItem;if(t.clientMessageId){this.confirmWorkCenterMessageEnvelope(e,s.id,t.clientMessageId);let u=Object.entries(this.workCenterPending||{}).find(([,f])=>f?.agentId===e&&f.clientMessageId===t.clientMessageId);if(u){let[f,p]=u;clearTimeout(p.timer),delete this.workCenterPending[f],p.resolve(t.type==="coordinator.turn_started"?{accepted:!0,turnId:null,receipt:!0}:t.workItem)}}let n=this.workCenterItemsByAgent[e]||[];if(t.type==="work_item.deleted"){this.removeWorkItemState(e,s.id);return}if(this.workItemDeleted(e,s.id))return;let r=this._workCenterListFiltersByAgent[e]||{},i=this._workCenterListEventsByAgent[e]?.[s.id]?.summary||null,o=n.some(u=>u?.id===s.id)?n:i?[i]:[],a=Er(o,s).find(u=>u?.id===s.id)||s,l=Number(this._workCenterListEventGenerationByAgent[e]||0)+1;this._workCenterListEventGenerationByAgent={...this._workCenterListEventGenerationByAgent,[e]:l},this._workCenterListEventsByAgent={...this._workCenterListEventsByAgent,[e]:{...this._workCenterListEventsByAgent[e]||{},[s.id]:{generation:l,queryKey:this._workCenterListQueryByAgent[e]||null,summary:a}}};let c=this.applyWorkItemBoardSummary(n,a,r);this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:c};let d=this.workCenterDetailByAgent[e];if(d?.id===s.id){let u=t.type==="run.finished"&&t.actionId&&Array.isArray(s.actionStats)&&s.actionStats.some(A=>A?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,f=zo(d,u),p=Number(s.coordinatorRevision),g=Number(d.coordinatorRevision)||0,b=Number.isInteger(p)&&p>g,h=Ld(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:$d(d,s)},h&&this.refreshWorkItemDetailAfterActionChange(e,s,b?null:f)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(b=>b?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(b=>b?.id===t.currentActionId)||t.currentAction,r=s?.actionId||t.currentActionId||null,i=Number(s?.generation??n?.generation),o=Number.isInteger(i)&&i>0?i:null,a=Number(t.coordinatorRevision),l=!s&&Number.isInteger(a)&&a>=0?a:null,c=Number(s?.attempt),d=Number.isInteger(c)&&c>=0?c:null,u=l!=null?`${t.id}:coordinator:${l}`:`${t.id}:${r}${o==null?"":`:${o}`}${d==null?"":`:${d}`}`;if(this._workCenterDetailEventRefreshByAgent[e]?.key===u)return;let f=this.beginWorkCenterDetailWrite(e),p={key:u,generation:f};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let g=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let b=await this.workCenterRequest("get",{id:t.id},e),h=this.workCenterDetailByAgent[e],A=h?.actions?.find(E=>E?.id===r),w=b?.actions?.find(E=>E?.id===r),S=o==null||tt(A?.generation)===o,y=o==null||tt(w?.generation)>=o,m=l==null||Number(b?.coordinatorRevision)===l,v=l!=null||S&&y&&(t.currentActionId==null?b?.currentActionId==null:h?.currentActionId===t.currentActionId&&b?.currentActionId===t.currentActionId);h?.id===t.id&&m&&v&&this.commitWorkCenterDetail(e,b,f)&&g&&await g}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let b={...this._workCenterDetailEventRefreshByAgent};delete b[e],this._workCenterDetailEventRefreshByAgent=b}}},cacheYeaftAgentStatus(e,t,{allowBootstrapCatalog:s=!1}={}){if(!e||!t)return;let n=this.yeaftStatusByAgent[e]||{},r=Number(n.catalogRevision)||0,i=Number(t.catalogRevision)||0,o=typeof n.catalogEpoch=="string"?n.catalogEpoch:"",a=typeof t.catalogEpoch=="string"?t.catalogEpoch:"",l=Number(n.catalogRefreshedAt)||0,c=Number(t.catalogRefreshedAt)||0,d=Array.isArray(t.availableModels),u=t.type==="yeaft_status"&&d&&(i>0||c>0),f=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&f.includes(a),g=!!a&&a===o,b=i>0?g&&i===r:c>0&&c===l,h=i>0?!!a&&(a!==o||i>r):r===0&&c>l,A=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,w=u&&!p&&(h||b&&A),y=w||s&&r===0&&l===0&&!u&&d,m={...t};if(!y)for(let E of Rh)delete m[E];let v={...n,...m};if(y){if(w&&o&&a&&o!==a){let E=[...f.filter(V=>V!==o),o].slice(-_h);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:E}}v.availableModels=t.availableModels,v.catalogRefreshedAt=w?c:null,v.catalogEpoch=w&&a||null,v.catalogRevision=w&&i||null,v.catalogDigest=w&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:v},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 Ie(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))},Mh),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=vc(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{bc(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},hc),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return yc(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return Po(this,e)},syncActiveYeaftHistoryLoad(){return Tn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;Bo(this);let n=ds(this),r=!e&&n?Ie(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]=[]),Sd(this),this.currentView="yeaft",No("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=ds(this),r=n?Ie(this,n):this.currentAgent,i=Pe(r,n),o=n?this.yeaftSessionHistoryState[i]:null,a=e||!this.yeaftSessionReady||!this.yeaftModel||!this.yeaftStatus,l=Number.isFinite(o?.latestSeq)?o.latestSeq:null,c=!!n&&!!this.yeaftConversationId&&Array.isArray(this.messagesMap?.[this.yeaftConversationId])&&this.messagesMap[this.yeaftConversationId].some(w=>w&&(w.sessionId??w.groupId??null)===n),d=!!n&&bo({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&ac(o,t);if(!a&&!d&&!u)return!1;let f=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===f)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=f);let g=null;n&&d?g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1}):n&&c&&!o?.loaded?(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...o||{},loaded:!0,loading:!1,hasMore:!!o?.hasMore,oldestSeq:Number.isFinite(o?.oldestSeq)?o.oldestSeq:null,count:o?.count||0,latestSeq:l}},this.yeaftLoadingMoreHistory=!1):n&&u&&(g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let b={type:"yeaft_load_history",agentId:r,sessionId:n,...g?{requestId:g.requestId}:{}};u?b.afterSeq=l:b.limit=d?Or:0;let h=An();b.perfTraceId=h;let A=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:h}),Xe(this,{traceId:h,phase:"history.request_send",agentId:r,sessionId:n,messageType:b.type,bytes:JSON.stringify(b).length,detail:{mode:A,limit:b.limit??null,afterSeq:b.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(b),!0},leaveYeaft(){this.activateChatView({persistPreference:!0})},fetchYeaftToolStats(){this.currentAgent&&(this.yeaftToolStatsLoading=!0,this.sendWsMessage({type:"yeaft_fetch_tool_stats",agentId:this.currentAgent}),this._fetchYeaftToolStatsTimer&&clearTimeout(this._fetchYeaftToolStatsTimer),this._fetchYeaftToolStatsTimer=setTimeout(()=>{this.yeaftToolStatsLoading&&(this.yeaftToolStatsLoading=!1,this.yeaftToolStats={...this.yeaftToolStats||{snapshot:{},registered:[],unused:[]},error:null,notice:"Tool stats are unavailable right now. Try again after the agent reconnects.",fetchedAt:Date.now()}),this._fetchYeaftToolStatsTimer=null},1e4))},loadYeaftDebugHistory({groupId:e,limit:t,dreamLimit:s,indexOnly:n=!1,detailTurnId:r=null,search:i=void 0}={}){if(!this.currentAgent)return;let o=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),a=typeof r=="string"&&r,l=o&&!a?iu:sa,c=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||l,d=Math.max(1,Math.min(l,c)),u=a?"detail":"list",f=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=JSON.stringify({agentId:this.currentAgent,groupId:e||null,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:a?"":o});if(this._yeaftDebugHistoryInFlightKey===p)return;this._yeaftDebugHistoryInFlightKey=p,a||(this._yeaftDebugHistoryLatestListRequestId=f),this.yeaftDebugHistoryLimit=d,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null;let g={type:"yeaft_fetch_debug_history",agentId:this.currentAgent,requestId:f,requestKind:u,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(g.indexOnly=!0),typeof r=="string"&&r?g.detailTurnId=r:o&&(g.search=o),typeof e=="string"&&e&&(g.sessionId=e),this.sendWsMessage(g),this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="Debug history is unavailable right now. Try again after the agent reconnects."),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null},1e4)},agentIdForSession(e){return Ie(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r}){let i=Ie(this,e);if(!e||!i)return;let o=Array.isArray(n)?n.filter(g=>g&&g.fileId):[],a=Dr(r),l=o.length>0;if(!t?.trim()&&!l)return;let c=t?.trim()?t:"(attached files)",d=`u_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,u=An();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[d]:u},Xe(this,{traceId:u,phase:"send.prepare",agentId:i,sessionId:e,turnId:d,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:o.length,quoted:!!a}});let f=Mt(this,e);if(f){let g={id:d,messageId:d,clientMessageId:d,type:"user",content:c,sessionId:e,turnId:d,...a?{quote:a}:{}};if(o.length>0&&(g.attachments=o.map(b=>({fileId:b.fileId,name:b.name,preview:b.preview,isImage:!!b.isImage,mimeType:b.mimeType||""}))),this.addMessageToConversation(f,g),this.processingConversations[f]=!0,e){let b=dt(i,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...b?{[b]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),kn(this,f)}let p={type:"yeaft_session_send",agentId:i,id:d,sessionId:e,text:c,mentions:Array.isArray(s)?s:[],perfTraceId:u,...a?{quote:a}:{}};o.length>0&&(p.attachments=o.map(g=>({fileId:g.fileId,isImage:!!g.isImage}))),Xe(this,{traceId:u,phase:"send.websocket_send",agentId:i,sessionId:e,turnId:d,messageType:p.type,bytes:JSON.stringify(p).length}),this.sendWsMessage(p)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=Ie(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[ea(i,n,r)]:!0},this.sendWsMessage({type:"yeaft_task_cancel",agentId:i,sessionId:n,taskId:r,clientRequestId:`task_cancel_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}),!0)},getYeaftMessageWindowKey(e=null){return e||this.yeaftActiveSessionFilter||"__all__"},pruneYeaftMessageWindow(e=null){if(this.currentView!=="yeaft")return;let t=this.getYeaftMessageWindowKey(e);this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[t]:{visibleTurns:cs()}}},expandYeaftMessageWindow(e=null,t=Ln()){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e),r=(this.yeaftMessageWindowState[s]?.visibleTurns||cs())+Math.max(1,Number.isFinite(t)?Math.floor(t):Ln());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:r}}},isYeaftMessageCached(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Mt(this,n);return!r||!t?!1:(this.messagesMap[r]||[]).some(i=>(!n||(i?.sessionId??i?.groupId??null)===n)&&((i?.id||i?.messageId)===t||i?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Mt(this,n);if(!r||!t)return!1;let i=(this.messagesMap[r]||[]).filter(u=>n?(u?.sessionId??u?.groupId??null)===n:!0),o=i.findIndex(u=>(u?.id||u?.messageId)===t||u?.persistedMessageId===t);if(o<0)return!1;let a=Ud(i),l=a.findIndex(u=>o>=u.start&&o<u.end);if(l<0)return!1;let c=Math.max(cs(),a.length-l),d=this.getYeaftMessageWindowKey(n);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[d]:{visibleTurns:c}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Ie(this,s,t),r=Pe(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,totalCount:null,loaded:!1,error:null},o=Mt(this,s),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(f=>[$n(f),f])),c=0;for(let f of a){if((f?.sessionId??f?.groupId??null)!==s)continue;let p=f.messageId||f.id;if(!p)continue;let g=f.type==="user"&&!!f.clientMessageId&&p===f.clientMessageId,b=f.type==="assistant"&&f.isStreaming===!0;if(!g&&!b)continue;let h=f.type,A=f.turnId||f.threadId||p,w=f.speakerVpId||f.vpId||null,S=$n({role:h,messageId:p,clientMessageId:f.clientMessageId,turnId:A,speakerVpId:w}),y=l.get(S),v=(typeof f.content=="string"?f.content:"").replace(/\s+/g," ").trim();l.set(S,{...y,messageId:Number.isFinite(y?.seq)?y.messageId:p,...f.clientMessageId?{clientMessageId:f.clientMessageId}:{},turnId:A,role:h,speakerVpId:w||y?.speakerVpId||null,timestamp:f.timestamp||f.ts||y?.timestamp||null,snippet:v.length>180?`${v.slice(0,180).trimEnd()}\u2026`:v||y?.snippet||""}),y||(c+=1)}let d=f=>{let p=typeof f=="number"?f:Date.parse(f||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((f,p)=>Number.isFinite(f.seq)&&Number.isFinite(p.seq)?f.seq-p.seq:d(f.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e){let t=e?.sessionId??e?.groupId??null,s=Ie(this,t),n=Pe(s,t),r=this.yeaftHistoryOutlineBySession[n];if(!t||!s||!r?.loaded||r.loading)return!1;let i=e?.type;if(i!=="user"&&i!=="assistant")return!1;let o=e.dbMessageId||e.messageId||e.id||null,a=Hh(o);if(!o||!Number.isFinite(a))return!1;let l=e.turnId||e.threadId||o,c=e.speakerVpId||e.vpId||null,u=(typeof e.content=="string"?e.content:"").replace(/\s+/g," ").trim(),f=$n({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(S=>[$n(S),S])),g=p.get(f);p.set(f,{...g,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||g?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||g?.snippet||""});let b=50,h=Array.from(p.values()).sort((S,y)=>(S.seq||0)-(y.seq||0)),A=h.length>b,w=h.slice(-b);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:w,hasMore:r.hasMore||A,nextBeforeSeq:A&&Number.isFinite(w[0]?.seq)?w[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!g?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null){let s=this.messagesMap[e]||[],n=null,r=[];for(let i=s.length-1;i>=0;i--){let o=s[i];if(o?.type==="user")break;if(t&&o?.turnId&&o.turnId!==t||o?.type!=="assistant")continue;let a=typeof o.content=="string"?o.content.replace(/\s+/g," ").trim():"";n?!String(n.content||"").trim()&&a&&(n=o):n=o,a&&r.unshift(a)}return n?this.promoteYeaftHistoryOutlineRow({...n,content:r.join(" ")}):!1},invalidateYeaftHistoryOutline(e){let t=Ie(this,e),s=Pe(t,e),n=this.yeaftHistoryOutlineBySession[s];return!e||!t||!n?!1:n.loading?(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0):(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}},this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e?this.loadYeaftHistoryOutline({force:!0}):!0)},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null}={}){if(this.currentView!=="yeaft"&&!s)return!1;let r=s||this.yeaftActiveSessionFilter||null,i=n||Ie(this,r);if(!r||!i)return!1;let o=Pe(i,r),a=this.getYeaftHistoryOutlineState(r,i);if(!e&&a.loaded&&!t)return!0;if(e&&(!a.hasMore||!Number.isFinite(a.nextBeforeSeq))||a.loading)return!1;if(!su(this,i,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...a,error:"unsupported",loading:!1}},!1;let l=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={...a,requestId:l,agentId:i,sessionId:r,loading:!0,requestAppend:e,refreshPending:!1,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:c};let d=this._yeaftHistoryOutlineTimeouts[o];d&&clearTimeout(d);let u=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[o];if(f?.requestId!==l)return;let p={...this._yeaftHistoryOutlineTimeouts};delete p[o],this._yeaftHistoryOutlineTimeouts=p;let g=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...f,requestId:null,loading:!1,requestAppend:!1,loaded:g?!1:f.loaded,refreshPending:!1,error:g?null:"timeout"}},g&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:r,targetAgentId:i})},1e4);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[o]:u},this.sendWsMessage({type:"yeaft_load_history_outline",agentId:i,sessionId:r,requestId:l,limit:50,...e&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{},includeTotal:!a.loaded}),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Pe(e.agentId,e.sessionId),s=this.yeaftHistoryOutlineBySession[t];if(!s||e.requestId!==s.requestId)return!1;let n=this._yeaftHistoryOutlineTimeouts[t];n&&clearTimeout(n);let r={...this._yeaftHistoryOutlineTimeouts};delete r[t],this._yeaftHistoryOutlineTimeouts=r;let i=Array.isArray(e.results)?e.results:[],o=s.requestAppend?[...s.results||[],...i]:i,a=new Map(o.filter(d=>d?.messageId).map(d=>[$n(d),d])),l=Array.from(a.values()).sort((d,u)=>(d.seq||0)-(u.seq||0)),c=s.refreshPending===!0;return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:c?!1:!e.error,results:l,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:c?null:e.error||null}},c&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId}),!0},searchYeaftHistory(e,{append:t=!1,senderKey:s=""}={}){if(this.currentView!=="yeaft")return!1;let n=typeof e=="string"?e.trim():"",r=typeof s=="string"&&(s==="user"||s.startsWith("vp:"))?s.slice(0,103):"",i=this.yeaftActiveSessionFilter||null,o=Ie(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||n.length<2&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!su(this,o,"session_history_search"))return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return this.yeaftHistorySearchState={requestId:l,agentId:o,sessionId:i,query:n,senderKey:r,loading:!0,results:t&&a.query===n&&a.senderKey===r?a.results:[],hasMore:!1,nextBeforeSeq:t&&a.query===n&&a.senderKey===r?a.nextBeforeSeq:null,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4),this.sendWsMessage({type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}}),!0},handleYeaftHistorySearchResult(e){let t=this.yeaftHistorySearchState||{};if(!e||e.requestId!==t.requestId||e.agentId!==t.agentId||e.sessionId!==t.sessionId||e.query!==t.query||(e.senderKey||"")!==t.senderKey)return!1;this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null);let s=Array.isArray(e.results)?e.results:[],n=new Map((t.results||[]).map(r=>[r.messageId,r]));for(let r of s)r?.messageId&&n.set(r.messageId,r);return this.yeaftHistorySearchState={...t,loading:!1,results:Array.from(n.values()),hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,error:e.error||null},!0},loadYeaftHistoryWindow(e){let t=this.yeaftActiveSessionFilter||null,s=Ie(this,t);if(!t||!s||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);if(this.isYeaftMessageCached(t,e.messageId))return Promise.resolve(!0);let n=Pe(s,`${t}:${e.messageId}`),r=this._yeaftHistoryWindowPendingByKey||{};if(r[n]?.promise)return r[n].promise;let i=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o=null,a=new Promise(c=>{o=c}),l=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[n]?.requestId!==i)return;let{[n]:d,...u}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=u,o(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...r,[n]:{requestId:i,agentId:s,sessionId:t,messageId:e.messageId,resolve:o,timeout:l,promise:a}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:s,sessionId:t,requestId:i,anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5}),a},async revealYeaftHistoryResult(e){let t=this.yeaftActiveSessionFilter||null,s=Ie(this,t),n=Mt(this,t);return!t||!s||!n||!e?.messageId||!await this.loadYeaftHistoryWindow(e)||this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==t||Ie(this,t)!==s||Mt(this,t)!==n?!1:this.revealYeaftMessage(t,e.messageId,n)},handleYeaftHistoryWindow(e,t=null){let n=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,c])=>c?.requestId===e?.requestId);if(!n)return!1;let[r,i]=n;if(e.agentId!==i.agentId||e.sessionId!==i.sessionId)return!1;clearTimeout(i.timeout);let{[r]:o,...a}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=a;let l=!e.error&&!!t&&this.isYeaftMessageCached(i.sessionId,i.messageId,t);return i.resolve(!!l),!!l},createYeaftSession({displayName:e,vpIds:t,defaultVpId:s,workDir:n,agentId:r}={}){let i=Array.isArray(t)?t.slice():[],o=s&&i.includes(s)?s:i[0]||null,a=(e||"").trim(),l=(n||"").trim(),c={roster:i,defaultVpId:o};return a&&(c.name=a),l&&(c.workDir=l),this.sessionCrudRequest("create",c,{agentId:r})},handleYeaftOutput(e){if(!e)return;let t=e.agentId||this.yeaftAgentId||this.currentAgent||null,s=e.conversationId||e.event?.conversationId||null,n=$s(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let i=mc(this,t,s);if(!i)return;let o=e.turnId?Bs(this,t,e.turnId):"",a=!!(o&&this.activeVpTurns?.[o])||(this.messagesMap?.[i]||[]).some(l=>l?.turnId===e.turnId&&(l.isStreaming||l.status==="pending"));if(!e.turnId||!a)return;e={...e,conversationId:i}}if(e.perfTraceId&&(Xe(this,{traceId:e.perfTraceId,phase:"receive.yeaft_output",agentId:e.agentId||null,sessionId:e.sessionId||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||e.event?.type||e.type}),e.turnId&&(this.yeaftPerfTraceByTurnId={...this.yeaftPerfTraceByTurnId||{},[e.turnId]:e.perfTraceId})),e.data){let i=e.agentId||this.yeaftAgentId||this.currentAgent||null,o=Wt(this,i,e.conversationId),a=e.turnId?Bs(this,e.agentId||null,e.turnId):"";if(a&&this.activeVpTurns?.[a]?.retryAttempt){let{retryAttempt:l,retryMax:c,retryDelayMs:d,retryReason:u,retryRecoveryMode:f,...p}=this.activeVpTurns[a];this.activeVpTurns={...this.activeVpTurns,[a]:p}}if(o){let l=e.sessionId??e.groupId??null,c=nu(this,l,i),d=i&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[i]:null,u=mt(this,i);u&&u.targetConversationId!==o?Cn(this,i,o):!u&&d&&d!==o&&!String(d).startsWith("yeaft-local-")&&(ht(this,d,o,{removeSource:d!==this.yeaftConversationId}),Sn(this,i,d,o)),Io(this,i,o);let f=mt(this,i,o),p=f?.sourceConversationId||d,g=!c&&p===this.yeaftConversationId;if(this.currentView==="yeaft"&&i&&p&&p!==o){let y=!g&&(!!f||String(p).startsWith("yeaft-local-"));ht(this,p,o,{removeSource:y}),g?Cr(this,i,p,o):y&&In(this,i,o)}i&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:o}),(c||!this.yeaftConversationId)&&(this.yeaftConversationId=o),c&&(this.activeConversations=[o]),this.messagesMap[o]||(this.messagesMap[o]=[]),this.currentView==="yeaft"&&(e.data?.type==="user"||e.data?.type==="text_delta")&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter&&e.sessionId||null);let b=this._currentYeaftAgentId,h=this._currentYeaftSessionId,A=this._currentYeaftVpId,w=this._currentYeaftTurnId,S=this._currentYeaftThreadId;i&&(this._currentYeaftAgentId=i),l!=null&&(this._currentYeaftSessionId=l),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{this.currentView==="yeaft"&&l&&(!this.yeaftActiveSessionFilter||l===this.yeaftActiveSessionFilter)&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter?l:null);let m=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(o,e.data),e.perfTraceId){let M=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();Xe(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:M-m}),xr(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let v=e.data,E=v?.message?.id||v?.id||null,V=Oh(E),U=Array.isArray(v?.message?.content)?v.message.content:[],L=U.some(M=>M?.type==="tool_use"),D=!!v?.tool_use_result||U.some(M=>M?.type==="tool_result");if(l){let M=!D&&!Fh(this,o,l)&&(v?.type==="user"||v?.type==="assistant"&&!L)?V:null,T=Pe(e.agentId||null,l),C=this.yeaftSessionHistoryState[T]||{},R=Number.isFinite(C.latestSeq)?C.latestSeq:-1;M!==null&&M>R&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[T]:{...C,latestSeq:M}})}}finally{this._currentYeaftAgentId=b,this._currentYeaftSessionId=h,this._currentYeaftVpId=A,this._currentYeaftTurnId=w,this._currentYeaftThreadId=S}}return}let r=e.event;if(r)switch(r.type){case"project_mutation_result":this.finishProjectMutation(r,e.agentId||null);break;case"ask_user_question":{let i=Wt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=Xd(e,r,i),a=()=>{let l=this.messagesMap[i]||[],c=Jd(l,o,i);if(c){if(c.askAnswered||c.askExpired)return!0;c.toolName="AskUserQuestion",r.toolCallId&&!c.toolId&&(c.toolId=r.toolCallId),c.agentId=o.agentId||c.agentId||null,c.askRequestId=r.requestId,c.askQuestions=r.questions||[],c.askCreatedAt=r.createdAt||null,c.askExpiresAt=r.expiresAt||null,r.replay&&(c.askPending=!1,c.pendingAnswers=null,c.askSubmitGeneration=null),c.isHistory=!1;let f=eu(this,o);return f&&Jo(c,f),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0}if(!r.replay)return!1;let d={id:`ask-card-${r.requestId}`,type:"tool-use",toolName:"AskUserQuestion",toolId:r.toolCallId||null,toolInput:{questions:r.questions||[]},askRequestId:r.requestId,askQuestions:r.questions||[],askCreatedAt:r.createdAt||null,askExpiresAt:r.expiresAt||null,agentId:o.agentId,sessionId:o.sessionId,vpId:o.vpId,speakerVpId:o.vpId,turnId:o.turnId,threadId:o.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},u=eu(this,o);return u&&Jo(d,u),l.push(d),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0};if(!a()){let l=0,c=setInterval(()=>{l+=1,(a()||l>=10)&&clearInterval(c)},200)}break}case"ask_user_answered":case"ask_user_expired":{let i=Wt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=this.messagesMap[i]||[],a=Xd(e,r,i),l=Jd(o,a,i);if(!l){Vh(this,a,r);break}Jo(l,r),this.messagesMap={...this.messagesMap,[i]:o.slice()};break}case"session_ready":{let i=r.conversationId,o=e.agentId||this.currentAgent;if($s(this,o,i))break;let a=o&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[o]:null,l=this.yeaftConversationId?String(this.yeaftConversationId):"",c=l.startsWith("yeaft-local-")&&(!o||l.startsWith(`yeaft-local-${o}-`)||/^yeaft-local-\d/.test(l))?this.yeaftConversationId:null,d=a||c,u=r.sessionId||e.sessionId||null,f=nu(this,u,o),p=mt(this,o);p&&p.targetConversationId!==i?Cn(this,o,i):!p&&a&&a!==i&&!String(a).startsWith("yeaft-local-")&&Sn(this,o,a,i),Io(this,o,i);let b=mt(this,o,i)?.sourceConversationId||d,h=!f&&b===this.yeaftConversationId;if(b&&b!==i){let m=!h;ht(this,b,i,{removeSource:m}),h?Cr(this,o,b,i):m&&In(this,o,i)}else this.messagesMap[i]||(this.messagesMap[i]=[]);o&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[o]:i},this.cacheYeaftAgentStatus(o,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,o?this.applyCachedYeaftStatus(o):this.yeaftAvailableModels=r.availableModels||[]);let A=Array.isArray(r.tasks)?r.tasks:[],w={};for(let[m,v]of Object.entries(this.yeaftActiveTasksBySession||{})){let E=Object.fromEntries(Object.entries(v||{}).filter(([,U])=>U?.id&&(U.agentId&&U.agentId!==o||na.has(U.status)))),V=ta(E);Object.keys(V).length>0&&(w[m]=V)}for(let m of A){if(!m?.id||!m.sessionId||m.status!=="running")continue;let v=Pe(o,m.sessionId);w[v]={...w[v]||{},[m.id]:{...m,agentId:o}}}this.yeaftActiveTasksBySession=w,f&&(r.yeaftDir&&(this.yeaftYeaftDir=r.yeaftDir),this.yeaftStatus={skills:r.skills,mcpServers:r.mcpServers,tools:r.tools,multiVp:!!r.multiVp}),(f||!this.yeaftConversationId)&&(this.yeaftConversationId=i),f&&(this.activeConversations=[i]);let S=e.agentId||this.currentAgent||null,y=S||"__current__";this._yeaftVpSubscribedAgentKey!==y&&(this._yeaftVpSubscribedAgentKey=y,this.sendWsMessage(S?{type:"yeaft_vp_subscribe",agentId:S}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let i=e.agentId||this.currentAgent;i&&this.cacheYeaftAgentStatus(i,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let i={turnId:r.turnId,userPrompt:r.userPrompt||"",vpId:r.vpId||e.vpId||null,sessionId:r.sessionId||e.sessionId||null,openedAt:r.at||Date.now(),closedAt:null,totalMs:0,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:i},this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,closedAt:Date.now(),totalMs:r.totalMs||0,totalTokens:r.totalTokens||0,loopCount:r.loopCount||i.loopCount||0}};break}case"memory_used":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let i=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let a=this.yeaftDebugTurnsById[r.turnId];a&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,dreamMemoryLoaded:i,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let o={};for(let a of i){let l=a&&typeof a.scope=="string"?a.scope:null,c=l&&/^sessions\/[^/]+$/.test(l)?l:l&&/^group\/[^/]+$/.test(l)?`sessions/${l.slice(6)}`:null;c&&(o[c]={scope:c,sourceScope:l,sessionId:c.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:a.summary||"",truncated:!!a.truncated,receivedAt:Date.now()})}Object.keys(o).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...o});break}case"memory_adjust":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryAdjust:{sessionKey:r.sessionKey||null,added:r.added||0,evicted:r.evicted||0,skipped:r.skipped||0,reason:r.reason||""}}};break}case"tool_exec":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;let o=[...i.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError,toolOutput:r.toolOutput==null?null:String(r.toolOutput)}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,tools:o}};break}case"loop":{if(this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,systemPrompt:r.systemPrompt,messages:r.messages,response:r.response,toolCalls:r.toolCalls,usage:r.usage||{inputTokens:0,outputTokens:0,totalTokens:0},latencyMs:r.latencyMs,ttfbMs:r.ttfbMs,stopReason:r.stopReason,at:typeof r.at=="number"?r.at:null,rawRequest:r.rawRequest||null,rawResponse:r.rawResponse||null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>ru){let i=Pd({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(ru,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=i.loops,this.yeaftDebugTurnsById=i.turnsById,this.yeaftDebugTurnOrder=i.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let i=Bs(this,e.agentId||null,e.turnId),o=this.activeVpTurns?.[i];if(!o)break;let a=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[i]:{...o,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:a,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"consolidate":case"fallback":case"thinking_delta":break;case"reflection":{let i=Wt(this,e.agentId||null,e.conversationId)||"unknown",o=Array.isArray(r.loopRange)?r.loopRange:[0,0],a=`${i}:${r.trigger}:${o[0]}-${o[1]}`,l=this.yeaftReflectionCards[a],c=this.messagesMap[i]||[],d=l?l.anchorMsgId:c.length>0&&c[c.length-1].id||null,u=l?l.anchorOrder:c.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[a]:{key:a,conversationId:i,turnId:r.turnId||l&&l.turnId||null,loopNumber:r.loopNumber||l&&l.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:o,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:d,anchorOrder:u,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let i=r.task;if(!i?.id||!i.sessionId)break;let o=e.agentId||Ie(this,i.sessionId),a=Pe(o,i.sessionId),l={...i,agentId:o},c={...this.yeaftActiveTasksBySession},d={...c[a]||{}};i.status==="running"||na.has(i.status)?d[i.id]=l:delete d[i.id];let u=ta(d);if(Object.keys(u).length>0?c[a]=u:delete c[a],this.yeaftActiveTasksBySession=c,i.status!=="running"){let{[ea(o,i.sessionId,i.id)]:f,...p}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=p}break}case"yeaft_task_cancel_result":{let i=r.taskId||r.task?.id||null,o=r.task?.sessionId||r.sessionId||e.sessionId||null,a=e.agentId||Ie(this,o);if(i&&o&&r.success===!1){let{[ea(a,o,i)]:c,...d}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=d}let l=r.task;if(l?.id&&l.sessionId){let c=Pe(a,l.sessionId),d={...this.yeaftActiveTasksBySession},u={...d[c]||{}};u[l.id]={...l,agentId:a};let f=ta(u);Object.keys(f).length>0?d[c]=f:delete d[c],this.yeaftActiveTasksBySession=d}break}case"sub_agent_event":{let i=Wt(this,e.agentId||null,e.conversationId)||"unknown",o=r.agentId;if(!o)break;let a=r.payload||{},l=`${i}:${o}`,c=this.yeaftSubAgentCards[l],d=this.messagesMap[i]||[],u=c?c.anchorMsgId:d.length>0&&d[d.length-1].id||null,f=c?c.anchorOrder:d.length,p=c?{...c}:{key:l,conversationId:i,agentId:o,agentName:a.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:u,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(a.agentName&&!p.agentName&&(p.agentName=a.agentName),a.type){case"sub_agent_status":p.status=a.status||p.status,a.error&&(p.error=a.error);break;case"text_delta":break;case"tool_use":case"tool_call":p.toolCallCount=Number(p.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{p.turns+=1;let g=typeof a.content=="string"?a.content.trim():"";g&&(p.text=p.text?`${p.text}
|
|
8
|
+
`))}function $r(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||Yo.has(l?.status)||Yo.has(l?.turnEndReason)||Yo.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 Yo,Vr=F(()=>{Yo=new Set(["aborted","errored","error","cancelled","canceled"])});function Go(e){return e?.type==="user"&&typeof e.content=="string"&&e.content.trim()}function Qo(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 Xo(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 Ud(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(Go(i)||i.type==="system"||i.type==="error"){n(r),s={start:r,kind:i.type};continue}if(!Qo(i)){s||(s={start:r,kind:"other"});continue}(!s||s.kind==="assistant"&&Xo(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 jd(e,t){return t?e&&(e.sessionId??e.groupId)===t:!0}function Zo(e=[],t=null,s=5){let n=Math.max(1,Number.isFinite(s)?Math.floor(s):5),r=[],i=[],o=null,a=c=>{o&&(i.push({start:o.start,end:c,kind:o.kind}),o=null)};for(let c of e){if(!jd(c,t))continue;let d=r.length;if(r.push(c),Go(c)||c.type==="system"||c.type==="error"){a(d),o={start:d,kind:c.type};continue}if(!Qo(c)){o||(o={start:d,kind:"other"});continue}(!o||o.kind==="assistant"&&Xo(o,c))&&(a(d),o={start:d,kind:"assistant",turnId:c.turnId||"",speakerVpId:c.speakerVpId||c.vpId||""}),o.lastTurnId=c.turnId||o.lastTurnId||"",o.speakerVpId=o.speakerVpId||c.speakerVpId||c.vpId||""}if(a(r.length),i.length<=n)return r;let l=i[i.length-n];return r.slice(l.start)}function zd(e=[],t=null,s=5){let n=Math.max(1,s||5),r=0,i=null,o=()=>i?(i=null,r+=1,r>n):!1;for(let a of e)if(jd(a,t)){if(Go(a)||a.type==="system"||a.type==="error"){if(o())return!0;i={kind:a.type};continue}if(!Qo(a)){i||(i={kind:"other"});continue}if(!i||i.kind==="assistant"&&Xo(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 ds(){return 5}function Ln(){return 20}var Kd=F(()=>{});function xh(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=ps();for(let r of n?.sessionList||[])r?.id===t&&r?.agentId&&s.add(r.agentId)}return s}function au(e,t){let s=xh(e,t);return s.size===1?s.values().next().value:null}function qr(e,t,s){return!!s&&au(e,t)===s}function pt(e,t,s){return!e||e.sessionId!==t?!1:s?e.agentId===s:!e.agentId}function Yd(e,t,s=null){if(!t)return!1;let n=s||Ie(e,t),r=dt(n,t);if(r&&e.yeaftProcessingSessions?.[r]||e.yeaftProcessingSessions?.[t]&&qr(e,t,n))return!0;for(let i of Object.values(e.activeVpTurns||{}))if(pt(i,t,n))return!0;for(let i of Object.values(e.vpStatuses||{}))if(pt(i,t,n)&&Nr.has(i?.state))return!0;return!1}function Th(e,t,s,n=null){let r={...e.yeaftProcessingSessions||{}};if(t){let i=Fo(t);if(r=Object.fromEntries(Object.entries(r).filter(([o])=>n?o!==dt(t,n):!o.startsWith(i))),n)qr(e,n,t)&&delete r[n];else for(let o of Object.keys(r))qr(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||!Nr.has(i?.state))continue;let a=dt(t,o)||o;r[a]=!0}return r}function Bs(e,t,s){let n=Oo(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 Gd(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=Fo(t);e.yeaftProcessingSessions=Object.fromEntries(Object.entries(e.yeaftProcessingSessions||{}).filter(([n])=>!n.startsWith(s)))}function Tt(e,t){return`${e||""}:${t||""}`}function Eh(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 Dh(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 Lh(e={}){return{agentId:e.agentId||"",workItemId:e.workItemId||"",target:Eh(e.target),text:String(e.text||""),attachments:Array.isArray(e.attachments)?e.attachments.map(t=>({fileId:t?.fileId||"",name:t?.name||"",mimeType:t?.mimeType||"",size:Math.max(0,Number(t?.size)||0)})):[],revision:Number(e.revision)||0,planRevision:Number(e.planRevision)||0,ledgerRevision:Number(e.ledgerRevision)||0,coordinatorRevision:Number(e.coordinatorRevision)||0}}function Xd(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 Zd(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 $h(e,t){return ra.every(s=>!t[s]||e[s]===t[s])}function lu(e,t){return ra.every(s=>!e[s]||!t[s]||e[s]===t[s])}function Jd(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=>$h(Zd(o,s),t));if(r.length===1)return r[0];let i=n.filter(o=>lu(Zd(o,s),t));return i.length===1?i[0]:null}function cu(e){return ra.map(t=>e[t]||"").join("\0")}function Vh(e,t,s){let n=cu(t),r={...e._yeaftAskTerminalEvents||{},[n]:{identity:t,event:s,receivedAt:Date.now()}},i=Object.keys(r);if(i.length>Qd){i.sort((o,a)=>r[o].receivedAt-r[a].receivedAt);for(let o of i.slice(0,i.length-Qd))delete r[o]}e._yeaftAskTerminalEvents=r}function eu(e,t){let s=e._yeaftAskTerminalEvents||{},n=cu(t),r=s[n]?n:null;if(!r){let l=Object.entries(s).filter(([,c])=>lu(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 Fh(e,t,s){return(e.messagesMap?.[t]||[]).some(n=>n?.type==="tool-use"&&n.sessionId===s&&n.hasResult===!1)}function Jo(e,t){t.type==="ask_user_answered"?(e.askAnswered=!0,e.selectedAnswers=t.answers||{},e.askExpired=!1):(e.isHistory=!0,e.askExpired=!0,e.askAnswered=!1,e.selectedAnswers=null),e.askPending=!1,e.pendingAnswers=null,e.askSubmitGeneration=null,e.askRequestId=null}function Oh(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 Hh(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 $n(e){return e?.role==="assistant"&&e?.turnId?`response:${e.turnId}:${e.speakerVpId||e.vpId||""}`:e?.clientMessageId?`client:${e.clientMessageId}`:`message:${e?.messageId||""}`}function tu(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function ea(e,t,s){return`${dt(e,t)}::${s||""}`}function ta(e){let t=Object.entries(e||{}),s=t.filter(([,r])=>r?.status==="running"),n=t.filter(([,r])=>r&&r.status!=="running"&&na.has(r.status)).sort((r,i)=>tu(i[1])-tu(r[1])).slice(0,Ph);return Object.fromEntries([...s,...n])}function ps(){try{return typeof window>"u"?null:window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore()||null}catch{return null}}function Ie(e,t,s=null){if(s)return s;if(t){let n=ps(),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 qh(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 su(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"&&qh(n?.version||r?.version,"1.0.166")}function us(e,{fallbackDefault:t=!1}={}){if(e?.yeaftActiveSessionFilter)return e.yeaftActiveSessionFilter;let s=ps();return s?.activeSessionId?s.activeSessionId:t?"grp_default":null}function Hr(e){let t=e.yeaftDebugSessionFilter;if(t==="__all__")return null;if(t)return t;let s=us(e);return s||(ps()?.sessions?.grp_default?"grp_default":null)}function Wt(e,t,s=null){return s||t&&e?.yeaftConversationIdsByAgent?.[t]||e?.yeaftConversationId||null}function Mt(e,t=null){let s=t||e?.yeaftActiveSessionFilter||null,n=Ie(e,s);return(n&&e?.yeaftConversationIdsByAgent?e.yeaftConversationIdsByAgent[n]:null)||e?.yeaftConversationId||null}function nu(e,t,s){if(e?.currentView!=="yeaft")return!1;let n=e?.yeaftActiveSessionFilter||null;if(n&&t!==n)return!1;let r=Ie(e,n);return!r||!s||r===s}var Ah,Fe,Fr,Or,Mh,Ph,na,Nr,Rh,_h,Qd,ra,ru,sa,iu,ou,fs,Br=F(()=>{ct();ao();xt();po();Ds();Vc();Kc();yd();ss();Nt();Cd();Co();Sr();Td();Md();Rd();co();Ko();To();cs();Vr();Tr();_o();Rn();Kd();({defineStore:Ah}=Pinia),Fe=Object.freeze([]),Fr=(e,t,s)=>`${e||""}::${t||""}::${s}`;Or=5,Mh=15e3,Ph=8,na=new Set(["succeeded","failed","cancelled","orphaned"]),Nr=new Set(["typing","thinking","retrying","streaming","tool"]),Rh=Object.freeze(["model","availableModels","refreshedAt","catalogRefreshedAt","catalogEpoch","catalogRevision","catalogDigest","refreshStartedAt","refreshReason","refreshError","refreshing"]),_h=8,Qd=64;ra=Object.freeze(["conversationId","agentId","requestId","toolCallId","sessionId","vpId","turnId","threadId"]);ru=1e3,sa=1,iu=5,ou=200,fs=Ah("chat",{state:()=>({ws:null,authenticated:!1,_hasHandledAgentList:!1,_hasHandledYeaftSessionHydrate:!1,yeaftSessionInventoryCompleteSupported:null,yeaftSessionHydrateRequestId:null,yeaftSessionHydrateSlices:[],yeaftSessionHydrateError:null,_yeaftSessionInventorySocketQuarantined:!1,sessionKey:null,serverEncryptionRequired:!0,connectionState:"disconnected",reconnectAttempts:0,maxReconnectAttempts:10,reconnectTimer:null,agents:[],currentAgent:null,currentAgentInfo:null,conversations:[],activeConversations:[],currentWorkDir:null,messagesMap:{},chatSessionState:{},panels:[],activePanelId:null,_pendingPaneId:null,conversationTitles:{},customConversationTitles:{},processingConversations:{},yeaftProcessingSessions:{},yeaftUnreadSessionKeys:{},theme:localStorage.getItem("theme")||(typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),themeFollowSystem:!localStorage.getItem("theme"),locale:localStorage.getItem("locale")||"zh-CN",executionStatusMap:{},sessionHealth:{},historySessions:[],historySessionsLoading:!1,folders:[],foldersLoading:!1,providerModels:[],providerModelsLoading:!1,contextUsage:null,lastUsedAgent:localStorage.getItem("lastUsedAgent")||null,lastUsedSession:JSON.parse(localStorage.getItem("lastUsedSession")||"null"),lastViewedConversation:localStorage.getItem("lastViewedConversation")||null,pendingRecovery:null,recoveryDismissed:!1,sessionLoading:!1,sessionLoadingText:"",agentSwitching:!1,pendingAgentSelection:null,_pendingSessionTitle:null,workbenchExpanded:!1,workbenchMaximized:!1,sidebarCollapsed:!1,sessionSidebarOpen:!1,compactStatus:null,clearStatus:null,refreshingSession:!1,refreshingSessionMap:{},proxyPorts:{},hasMoreMessages:!1,loadingMoreMessages:!1,chatHistoryRequests:{},chatHistoryRequestIdSupported:null,chatHistoryConnectionGeneration:0,sessionCatalog:[],sessionProjects:[],sessionCatalogLoaded:!1,sessionCatalogMutationRequests:{},projectMutationRequests:{},activeCatalogKey:null,openUnifiedSessionCreate:!1,openUnifiedChatCreate:!1,pendingUnifiedSessionSettings:null,yeaftHasMoreHistory:!1,yeaftLoadingMoreHistory:!1,yeaftOldestLoadedSeq:null,yeaftHistoryLoadError:null,yeaftSessionHistoryState:{},yeaftMessageWindowState:{},yeaftBootstrapMetaLoadingKey:null,yeaftHistoryPerfTraceBySession:{},yeaftHistorySearchState:{requestId:null,agentId:null,sessionId:null,query:"",senderKey:"",loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},yeaftHistoryOutlineBySession:{},_yeaftHistoryOutlineTimeouts:{},_yeaftHistorySearchTimeout:null,_yeaftHistoryWindowPendingByKey:{},_yeaftReconnectCatchUpPending:!1,_yeaftOpenedSessionsLoadedAgents:{},_yeaftAgentSeen:null,slashCommandsMap:{},slashCommandDescriptions:{},inputDrafts:{},mcpServers:{},expertRoleDefinitions:null,llmConfig:{},llmModelDiscovery:{},llmGithubDevice:null,modelsDevRegistry:{registry:{},fetchedAt:0,error:null,loaded:!1},_modelsDevPending:null,yeaftSettings:{},searchSettings:null,tavilyUsage:null,tavilyUsageLoading:!1,_perfTraceQueue:[],_perfTraceFlushTimer:null,yeaftPerfTraceByMessageId:{},yeaftPerfTraceByTurnId:{},yeaftMcpServers:[],yeaftMcpRuntime:{connected:!1,toolCount:0,perServer:[]},yeaftMcpLoading:!1,yeaftMcpError:null,btwMode:!1,btwMessages:[],btwLoading:!1,btwSessionId:null,conversationMcpServers:{},conversationMcpServerTools:{},mcpPanelOpen:!1,expertSelections:[],customExpertRoles:[],subagents:{},activeSubagentId:null,activeRightPanel:null,pinnedSessions:JSON.parse(localStorage.getItem("pinned-sessions")||"[]"),...kd(),workCenterOpen:!1,workCenterAgentId:null,workCenterItemsByAgent:{},workCenterListPageByAgent:{},workCenterListMoreLoadingByAgent:{},_workCenterListGenerationByAgent:{},_workCenterListQueryByAgent:{},_workCenterListFiltersByAgent:{},_workCenterListMoreRequestsByAgent:{},_workCenterListEventGenerationByAgent:{},_workCenterListEventsByAgent:{},_workCenterDeletedIdsByAgent:{},workCenterDetailByAgent:{},workCenterActionMessages:{},workCenterActionMessagesLoading:{},workCenterActionMessagesError:{},workCenterActionRequests:{},workCenterActionRequestDetails:{},workCenterActionRequestsLoading:{},workCenterActionRequestsError:{},workCenterActionRequestDetailsLoading:{},workCenterActionRequestDetailsError:{},workCenterLoadedByAgent:{},workCenterLoadingByAgent:{},workCenterErrorByAgent:{},workCenterWatcherByAgent:{},workCenterSettingsByAgent:{},workCenterRuntimeByAgent:{},workCenterSettingsLoadingByAgent:{},workCenterSettingsErrorByAgent:{},_workCenterSettingsGenerationByAgent:{},_workCenterDetailRequestGenerationByAgent:{},_workCenterDetailEventRefreshByAgent:{},_workCenterActionInputGenerationByAgent:{},_workCenterActionMessageRequests:{},_workCenterActionMessageGenerationByKey:{},_workCenterActionRequestsGeneration:{},_workCenterActionRequestDetailsGeneration:{},workCenterPending:{},workCenterComposerDrafts:{},workCenterMessageOutbox:{},_workCenterBrowserFence:null,_workCenterBrowserUnsubscribe:null,workCenterCreateDraft:null,yeaftConversationId:null,yeaftConversationIdsByAgent:{},_yeaftPendingConversationPromotions:{},_yeaftRetiredConversationIdsByAgent:{},_yeaftRetiredConversationTargetsByAgent:{},yeaftSessionAgentById:{},yeaftModel:null,yeaftModelEffort:null,yeaftSessionReady:!1,yeaftStatus:null,yeaftAvailableModels:[],yeaftStatusByAgent:{},_yeaftRetiredCatalogEpochsByAgent:{},yeaftModelsRefreshing:!1,yeaftModelRefreshError:null,yeaftYeaftDir:null,yeaftActiveTasksBySession:{},yeaftStoppingTasksById:{},yeaftToolStats:null,yeaftToolStatsLoading:!1,yeaftDebugLoops:[],yeaftDebugTurnsById:{},yeaftDebugTurnOrder:[],yeaftDebugHistoryLoading:!1,yeaftDebugHistoryError:null,yeaftDebugHistoryFetchedAt:0,yeaftDebugHistoryLimit:sa,yeaftDebugHistoryHasMore:!1,yeaftDebugSearch:"",yeaftDebugSessionFilter:null,yeaftDreamLatest:{},yeaftDreamSnapshots:{},yeaftDreamPromptLoads:{},yeaftDreamEvents:{},yeaftReflectionCards:{},yeaftSubAgentCards:{},yeaftSidebarV2Enabled:!0,yeaftActiveSessionFilter:null,_currentYeaftSessionId:null,_currentYeaftVpId:null,_currentYeaftTurnId:null,_currentYeaftThreadId:null,_yeaftAskTerminalEvents:{},activeVpTurns:{},vpStatuses:{},stoppingVpTurnIds:{},yeaftVpTyping:{},_vpCrudPending:null}),getters:{currentConversation:e=>e.activeConversations[0]||null,activeConversationId:e=>Wo(e),activeSessionRoute(e){if(e.currentView==="yeaft"){let n=us(e);return n?{runtimeProvider:"yeaft",agentId:Ie(e,n),sessionId:n}:null}let t=Wo(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]||Fe;if(e.currentView==="yeaft"){let n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||ds();return Zo(s,e.yeaftActiveSessionFilter||null,r)}return s},yeaftAllMessages:e=>{let t=Mt(e);return t&&e.messagesMap[t]||Fe},yeaftVisibleMessages(e){let t=Mt(e),s=t&&e.messagesMap[t]||Fe,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||ds();return Zo(s,e.yeaftActiveSessionFilter||null,r)},hasHiddenYeaftMessages(e){if(e.currentView!=="yeaft")return!1;let t=Mt(e),s=t&&e.messagesMap[t]||Fe,n=e.yeaftActiveSessionFilter||"__all__",r=e.yeaftMessageWindowState[n]?.visibleTurns||ds();return zd(s,e.yeaftActiveSessionFilter||null,r)},activeYeaftHistoryState(e){return Ro(e)},yeaftInitialHistoryLoading(e){let t=Ro(e);return e.currentView==="yeaft"&&!!e.yeaftActiveSessionFilter&&!!t?.loading&&!t?.loaded&&this.yeaftVisibleMessages.length===0},vpsTypingInCurrentConv(e){let t=this.activeConversationId;if(!t)return Fe;let s=(e.yeaftVpTyping||{})[t];if(!s)return Fe;let n=Object.keys(s).filter(r=>(s[r]||0)>0);return n.length===0?Fe: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=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamLatest?.[s]||null},yeaftDreamSnapshotForActiveSession(e){let t=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamSnapshots?.[s]||null},yeaftDreamPromptLoadForActiveSession(e){let t=Hr(e);if(!t)return null;let s=`sessions/${t}`;return e.yeaftDreamPromptLoads?.[s]||null},yeaftDreamEventsForActiveSession(e){let t=Hr(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||Fe,s=e.yeaftDebugTurnsById||{},n=e.yeaftDebugLoops||Fe,r=e.yeaftReflectionCards||{},i=e.yeaftDebugSessionFilter,o;i==="__all__"?o=null:i?o=i:o=null;let a={};for(let d of n)!d||!d.turnId||(a[d.turnId]||(a[d.turnId]=[]),a[d.turnId].push(d));let l={};for(let d of Object.keys(r)){let u=r[d];!u||!u.turnId||(l[u.turnId]||(l[u.turnId]=[]),l[u.turnId].push(u))}let c=[];for(let d=t.length-1;d>=0;d--){let u=t[d],f=s[u];if(!f||o&&f.sessionId&&f.sessionId!==o)continue;let p=a[u]||Fe,g=l[u]||Fe,b=p.length,h=0,A=0;for(let y of p){let m=y&&y.usage;m&&Number.isFinite(m.totalTokens)?h+=m.totalTokens:m&&(h+=(m.totalInputTokens||(m.inputTokens||0)+(m.cacheReadTokens||0)+(m.cacheWriteTokens||0))+(m.outputTokens||0)),y&&Number.isFinite(y.latencyMs)&&(A+=y.latencyMs)}let w=!f.closedAt,S={...f,loopCount:w||!f.loopCount?b:f.loopCount,totalTokens:w||!f.totalTokens?h:f.totalTokens,totalMs:w||!f.totalMs?A:f.totalMs,loops:p,reflections:g};c.push(S)}return c},yeaftDebugAvailableSessions:e=>{let t=new Set;for(let s of e.yeaftDebugTurnOrder||Fe){let n=e.yeaftDebugTurnsById[s];n&&n.sessionId&&t.add(n.sessionId)}return Array.from(t).sort()},yeaftDebugTurnTotal:e=>(e.yeaftDebugTurnOrder||Fe).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=us(e);return t?Yd(e,t,Ie(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"?ps()?.activeSession?.workDir||e.yeaftYeaftDir||e.currentAgentInfo?.workDir||"":e.currentWorkDir||e.currentAgentInfo?.workDir||"",currentAgentCapabilities:e=>e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"],hasCapability:e=>t=>(e.currentAgentInfo?.capabilities||["terminal","file_editor","background_tasks"]).includes(t),getConversationTitle:e=>t=>e.customConversationTitles[t]||e.conversationTitles[t]||null,executionStatus:e=>e.currentConversation?e.executionStatusMap[e.currentConversation]||{currentTool:null,toolHistory:[],lastActivity:null}:{currentTool:null,toolHistory:[],lastActivity:null},isConversationProcessing:e=>t=>!!e.processingConversations[t],isConversationConnecting:e=>t=>t?!!e.conversations.find(n=>n.id===t)?.connecting:!1,isConversationCompacting:e=>t=>t?e.compactStatus?.conversationId===t&&e.compactStatus?.status==="compacting":!1,isYeaftSessionProcessing:e=>(t,s=null)=>Yd(e,t,s),isYeaftSessionUnread:e=>(t,s=null)=>{if(!t)return!1;let n=Ie(e,t,s);return n?!!e.yeaftUnreadSessionKeys?.[yr(n,t)]:!1},showRecoveryBanner:e=>e.pendingRecovery&&!e.recoveryDismissed&&!e.currentConversation,currentSubagents:e=>{if(!e.currentConversation)return Fe;let t=e.subagents[e.currentConversation];return t?Object.values(t):Fe},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 Fe;let t=e.subagents[e.currentConversation];if(!t)return Fe;let s=t[e.activeSubagentId];return(Array.isArray(s?.messages)?s.messages:Fe).filter(r=>r?.type==="text")},selectedTaskInfo:()=>null,currentMcpServers:e=>e.currentConversation&&e.conversationMcpServers[e.currentConversation]||Fe},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&&No("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),Id(this),t&&s&&n&&(this.autoRestoreConversation(t),this.sendWsMessage({type:"refresh_conversation",conversationId:t}))},enterWorkCenter(e=null){if(!this.hydrateWorkCenterBrowserState())return!1;let t=this.agents.filter(n=>n?.online&&Array.isArray(n.capabilities)&&n.capabilities.includes("work_center")),s=t.some(n=>n.id===e)?e:t[0]?.id||null;if(!s)return this.workCenterOpen=!1,this.workCenterAgentId=null,!1;if(this.currentAgent!==s){this.selectAgent(s),this.currentAgent=s;let n=this.agents.find(r=>r.id===s);n&&(this.currentAgentInfo=n)}return this.workCenterAgentId=s,this.workCenterOpen=!0,this.listWorkItems(s).catch(()=>{}),!0},leaveWorkCenter(){this.workCenterOpen=!1},enterWorkCenterFromSession(e,t=""){if(!e?.id)return;let s=e.agentId||Ie(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=Al(()=>{gn(this._workCenterBrowserFence)||this.clearWorkCenterBrowserState()}));let e=hr();if(!e)return this._workCenterBrowserFence=null,this.workCenterComposerDrafts={},this.workCenterMessageOutbox={},!1;if(!gn(this._workCenterBrowserFence)){let t=Cl(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 Tt(e,t)},saveWorkCenterComposerDraft(e,t,s={}){let n=Tt(e,t);if(!e||!t)return;let r={...this.workCenterComposerDrafts||{},[n]:{text:String(s.text||""),attachments:Array.isArray(s.attachments)?s.attachments:[],target:Dh(s.target),error:String(s.error||"")}};return oo(r,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=r,!0):!1},loadWorkCenterComposerDraft(e,t){return this.workCenterComposerDrafts?.[Tt(e,t)]||null},removeWorkCenterComposerDraft(e,t){let s=Tt(e,t),n={...this.workCenterComposerDrafts||{}};return delete n[s],oo(n,this._workCenterBrowserFence)?(this.workCenterComposerDrafts=n,!0):!1},prepareWorkCenterMessageEnvelope(e={}){let t=Lh(e),s=Tt(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 mn(i,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=i,r):null},loadWorkCenterMessageEnvelope(e,t){return this.workCenterMessageOutbox?.[Tt(e,t)]||null},replaceWorkCenterMessageEnvelopeAttachments(e,t,s=[]){let n=Tt(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 mn(o,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=o,i):null},discardWorkCenterMessageEnvelope(e,t){let s=Tt(e,t),n={...this.workCenterMessageOutbox||{}};return delete n[s],mn(n,this._workCenterBrowserFence)?(this.workCenterMessageOutbox=n,!0):!1},confirmWorkCenterMessageEnvelope(e,t,s){let n=Tt(e,t),r=this.workCenterMessageOutbox?.[n];if(!r||r.clientMessageId!==s)return!1;let i={...this.workCenterMessageOutbox||{}};return delete i[n],mn(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=Er(e,t),r=n.find(i=>i?.id===t?.id)||null;return!r||this.workItemMatchesBoardQuery(r,s)?n:n.filter(i=>i.id!==r.id)},async listWorkItems(e=null,t={}){let s=e||this.workCenterAgentId||this.currentAgent;if(!s)return[];let n={lane:["needs_attention","active","closed"].includes(t.lane)?t.lane:null,keyword:String(t.keyword||t.search||"").trim(),vpId:String(t.vpId||"").trim(),workItemType:String(t.workItemType||"").trim(),createdFrom:Number(t.createdFrom)||null,createdTo:Number(t.createdTo)||null,updatedFrom:Number(t.updatedFrom)||null,updatedTo:Number(t.updatedTo)||null,limit:Math.min(Math.max(Number(t.limit)||100,1),200)},r=JSON.stringify(n),i=Number(this._workCenterListGenerationByAgent[s]||0)+1,o=Number(this._workCenterListEventGenerationByAgent[s]||0);this._workCenterListGenerationByAgent={...this._workCenterListGenerationByAgent,[s]:i},this._workCenterListQueryByAgent={...this._workCenterListQueryByAgent,[s]:r},this._workCenterListFiltersByAgent={...this._workCenterListFiltersByAgent,[s]:n},this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!0},this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:null};try{let a=await this.workCenterRequest("list",n,s),l=(Array.isArray(a?.items)?a.items:[]).filter(d=>!this.workItemDeleted(s,d?.id));if(this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&this.workCenterAgentId===s){let d=l,u=this._workCenterListEventsByAgent[s]||{};for(let f of Object.values(u))Number(f?.generation)<=o||f?.queryKey!==r||(d=this.applyWorkItemBoardSummary(d,f.summary,n));this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[s]:d},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[s]:{nextCursor:a?.nextCursor||null,queryKey:r}},this.workCenterWatcherByAgent={...this.workCenterWatcherByAgent,[s]:a?.watcher||null},this.workCenterLoadedByAgent={...this.workCenterLoadedByAgent,[s]:!0}}return l}catch(a){throw this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterErrorByAgent={...this.workCenterErrorByAgent,[s]:a?.message||String(a)}),a}finally{this._workCenterListGenerationByAgent[s]===i&&this._workCenterListQueryByAgent[s]===r&&(this.workCenterLoadingByAgent={...this.workCenterLoadingByAgent,[s]:!1})}},async loadMoreWorkItems(e=null){let t=e||this.workCenterAgentId||this.currentAgent,s=this.workCenterListPageByAgent[t],n=this._workCenterListFiltersByAgent[t];if(!t||!s?.nextCursor||!n)return[];let r=s.queryKey,i=this._workCenterListGenerationByAgent[t],o=Number(this._workCenterListEventGenerationByAgent[t]||0),a=s.nextCursor,l=`${i}:${r}:${a}`;if(this._workCenterListMoreRequestsByAgent[t]?.key===l)return this._workCenterListMoreRequestsByAgent[t].request;this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!0};let c=(async()=>{try{let d=await this.workCenterRequest("list",{...n,cursor:a},t),u=this.workCenterListPageByAgent[t];if(this._workCenterListGenerationByAgent[t]!==i||this._workCenterListQueryByAgent[t]!==r||u?.queryKey!==r||u?.nextCursor!==a||this.workCenterAgentId!==t)return[];let f=[...this.workCenterItemsByAgent[t]||[]];for(let g of Array.isArray(d?.items)?d.items:[]){if(this.workItemDeleted(t,g?.id))continue;let b=f.findIndex(h=>h.id===g.id);b<0?f.push(g):f[b]=Er([f[b]],g)[0]}let p=this._workCenterListEventsByAgent[t]||{};for(let g of Object.values(p))Number(g?.generation)<=o||g?.queryKey!==r||(f=this.applyWorkItemBoardSummary(f,g.summary,n));return this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[t]:f},this.workCenterListPageByAgent={...this.workCenterListPageByAgent,[t]:{nextCursor:d?.nextCursor||null,queryKey:r}},d?.items||[]}finally{if(this._workCenterListMoreRequestsByAgent[t]?.key===l){let d={...this._workCenterListMoreRequestsByAgent};delete d[t],this._workCenterListMoreRequestsByAgent=d,this.workCenterListMoreLoadingByAgent={...this.workCenterListMoreLoadingByAgent,[t]:!1}}}})();return this._workCenterListMoreRequestsByAgent={...this._workCenterListMoreRequestsByAgent,[t]:{key:l,request:c}},c},workItemDeleted(e,t){return!!this._workCenterDeletedIdsByAgent[e]?.[t]},removeWorkItemState(e,t){this._workCenterDeletedIdsByAgent={...this._workCenterDeletedIdsByAgent,[e]:{...this._workCenterDeletedIdsByAgent[e]||{},[t]:!0}},this.beginWorkCenterDetailWrite(e),this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:(this.workCenterItemsByAgent[e]||[]).filter(n=>n.id!==t)},this.workCenterDetailByAgent[e]?.id===t&&(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:null});let s=`${e}:${t}:`;for(let n of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError","workCenterActionRequests","workCenterActionRequestsLoading","workCenterActionRequestsError","workCenterActionRequestDetails","workCenterActionRequestDetailsLoading","workCenterActionRequestDetailsError","_workCenterActionMessageRequests","_workCenterActionMessageGenerationByKey","_workCenterActionRequestsGeneration","_workCenterActionRequestDetailsGeneration"]){let r={};for(let[i,o]of Object.entries(this[n]||{}))i.startsWith(s)||(r[i]=o);this[n]=r}},beginWorkCenterDetailWrite(e){let t=Number(this._workCenterDetailRequestGenerationByAgent[e]||0)+1;return this._workCenterDetailRequestGenerationByAgent={...this._workCenterDetailRequestGenerationByAgent,[e]:t},t},commitWorkCenterDetail(e,t,s){if(t?.id&&this.workItemDeleted(e,t.id)||s!=null&&Number(this._workCenterDetailRequestGenerationByAgent[e]||0)!==s)return!1;let n=this.workCenterDetailByAgent[e];return n?.id===t?.id&&Od(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=tt(n),i=qs(e,t,s,r);this._workCenterActionMessageGenerationByKey={...this._workCenterActionMessageGenerationByKey,[i]:Number(this._workCenterActionMessageGenerationByKey[i]||0)+1};for(let a of["workCenterActionMessages","workCenterActionMessagesLoading","workCenterActionMessagesError"]){let l={...this[a]};delete l[i],this[a]=l}let o={...this._workCenterActionMessageRequests};for(let a of Object.keys(o))a.startsWith(`${i}:`)&&delete o[a];return this._workCenterActionMessageRequests=o,i},async loadWorkItemActionMessages(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=tt(s),a=qs(i,e,t,o),l=Number(this._workCenterActionMessageGenerationByKey[a]||0),c=`${a}:${n==null?"latest":String(n)}`;if(this._workCenterActionMessageRequests[c])return this._workCenterActionMessageRequests[c];this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:!0},this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:null};let d=(async()=>{try{let u=await this.workCenterRequest("get_action_messages",{id:e,actionId:t,generation:o,cursor:n,limit:20},i);if(this.workItemDeleted(i,e)||tt(u?.generation)!==o||Number(this._workCenterActionMessageGenerationByKey[a]||0)!==l)return u;let f=this.workCenterActionMessages[a]?.messages||[],p=En(f,u?.messages||[]),g=this.workCenterActionMessages[a],b=g?.nextCursor,h=n==null?null:Number(n),A=b==null?null:Number(b),w=!g||h==null||A!=null&&h===A;return this.workCenterActionMessages={...this.workCenterActionMessages,[a]:{generation:o,messages:p,nextCursor:w?u?.nextCursor??null:b,total:Math.max(Number(u?.total)||0,Number(g?.total)||0,p.length)}},u}catch(u){throw Number(this._workCenterActionMessageGenerationByKey[a]||0)===l&&(this.workCenterActionMessagesError={...this.workCenterActionMessagesError,[a]:u?.message||String(u)}),u}finally{if(this._workCenterActionMessageRequests[c]===d){let u={...this._workCenterActionMessageRequests};delete u[c],this._workCenterActionMessageRequests=u;let f=Object.keys(u).some(p=>p.startsWith(`${a}:`));this.workCenterActionMessagesLoading={...this.workCenterActionMessagesLoading,[a]:f}}}})();return this._workCenterActionMessageRequests={...this._workCenterActionMessageRequests,[c]:d},d},async loadWorkItemActionRequests(e,t,s,n=null){let r=n||this.workCenterAgentId||this.currentAgent,i=tt(s),o=Dn(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)&&tt(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=tt(s),c=`${Dn(o,e,t,a)}:${n}:${r}`,d=Number(this._workCenterActionRequestDetailsGeneration[c]||0)+1;this._workCenterActionRequestDetailsGeneration={...this._workCenterActionRequestDetailsGeneration,[c]:d},this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!0},this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:null};try{let u=await this.workCenterRequest("get_action_request",{id:e,actionId:t,generation:a,runId:n,requestId:r},o),f=!this.workItemDeleted(o,e)&&tt(u?.generation)===a&&this._workCenterActionRequestDetailsGeneration[c]===d;return f&&(this.workCenterActionRequestDetails={...this.workCenterActionRequestDetails,[c]:u?.request||null}),f?u?.request||null:this.workCenterActionRequestDetails[c]||null}catch(u){throw this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsError={...this.workCenterActionRequestDetailsError,[c]:u?.message||String(u)}),u}finally{this._workCenterActionRequestDetailsGeneration[c]===d&&(this.workCenterActionRequestDetailsLoading={...this.workCenterActionRequestDetailsLoading,[c]:!1})}},async loadWorkCenterSettings(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("get_settings",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async refreshWorkCenterRuntime(e=null){let t=e||this.workCenterAgentId||this.currentAgent;if(!t)throw new Error("No Agent selected");let s=Number(this._workCenterSettingsGenerationByAgent[t]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[t]:s},this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!0},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:null};try{let n=await this.workCenterRequest("refresh_runtime",{},t);return this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[t]:n?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[t]:n?.runtime||null}),n}catch(n){throw this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[t]:n?.message||String(n)}),n}finally{this._workCenterSettingsGenerationByAgent[t]===s&&(this.workCenterSettingsLoadingByAgent={...this.workCenterSettingsLoadingByAgent,[t]:!1})}},async saveWorkCenterSettings(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent;if(!s)throw new Error("No Agent selected");let n=Number(this._workCenterSettingsGenerationByAgent[s]||0)+1;this._workCenterSettingsGenerationByAgent={...this._workCenterSettingsGenerationByAgent,[s]:n};let r=await this.workCenterRequest("update_settings",{settings:e},s);return this._workCenterSettingsGenerationByAgent[s]===n&&(this.workCenterSettingsByAgent={...this.workCenterSettingsByAgent,[s]:r?.settings||null},this.workCenterRuntimeByAgent={...this.workCenterRuntimeByAgent,[s]:r?.runtime||null},this.workCenterSettingsErrorByAgent={...this.workCenterSettingsErrorByAgent,[s]:null}),r},previewWorkCenterPlan(e={},t=null){let s=t||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview",e,s)},async createWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("create",e,s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async updateWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("update",{id:e,patch:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async startWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("start",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async cancelWorkItem(e,t=null){let s=t||this.workCenterAgentId||this.currentAgent,n=this.beginWorkCenterDetailWrite(s),r=await this.workCenterRequest("cancel",{id:e},s);return await this.listWorkItems(s,this._workCenterListFiltersByAgent[s]||{}),this.commitWorkCenterDetail(s,r,n),r},async resumeWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=this.beginWorkCenterDetailWrite(n),i=await this.workCenterRequest("resume",{id:e,revision:t},n);return await this.listWorkItems(n,this._workCenterListFiltersByAgent[n]||{}),this.commitWorkCenterDetail(n,i,r),i},async deleteWorkItem(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent,r=await this.workCenterRequest("delete",{id:e,revision:t},n);return this.removeWorkItemState(n,e),r},async postWorkItemMessage(e,t,s,n,r=[],i=null,o={}){if(!this.hydrateWorkCenterBrowserState())throw new Error("Work Center browser owner is unavailable; sign in again and retry");let a=i||this.workCenterAgentId||this.currentAgent,l=this.prepareWorkCenterMessageEnvelope({agentId:a,workItemId:e,target:s,text:t,attachments:r,revision:n,planRevision:o.planRevision,ledgerRevision:o.ledgerRevision,coordinatorRevision:o.coordinatorRevision});if(!l)throw new Error("Work Center browser owner changed; reopen Work Center and try again");let c=l.clientMessageId,d=this.workCenterDetailByAgent[a]?.id===e?this.workCenterDetailByAgent[a]:null,u=await this.workCenterRequest("post_work_item_message",{id:l.workItemId,clientMessageId:c,text:l.text,target:l.target,revision:l.revision,planRevision:l.planRevision||Number(d?.planRevision)||0,ledgerRevision:l.ledgerRevision||Number(d?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(l.coordinatorRevision))?Number(l.coordinatorRevision):Number(d?.coordinatorRevision)||0,attachments:l.attachments},a);if(l.target.kind==="coordinator"){if(!u?.accepted)throw new Error("Work Center Coordinator did not accept the message");return this.confirmWorkCenterMessageEnvelope(a,e,c),u}return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.confirmWorkCenterMessageEnvelope(a,e,c),u},async sendWorkItemMessage(e,t,s,n=[],r=null,i={}){let o=r||this.workCenterAgentId||this.currentAgent,a=this.workCenterDetailByAgent[o]?.id===e?this.workCenterDetailByAgent[o]:null,l=await this.workCenterRequest("work_item_message",{id:e,text:t,revision:s,planRevision:Number.isInteger(Number(i.planRevision))?Number(i.planRevision):Number(a?.planRevision)||0,ledgerRevision:Number.isInteger(Number(i.ledgerRevision))?Number(i.ledgerRevision):Number(a?.ledgerRevision)||0,coordinatorRevision:Number.isInteger(Number(i.coordinatorRevision))?Number(i.coordinatorRevision):Number(a?.coordinatorRevision)||0,attachments:Array.isArray(n)?n:[]},o);if(!l?.accepted)throw new Error("Work Center Coordinator did not accept the message");return l},async retryWorkItemAction(e,t,s,n,r=null){let i=r||this.workCenterAgentId||this.currentAgent,o=this.beginWorkCenterDetailWrite(i),a=await this.workCenterRequest("retry_action",{id:e,actionId:t,revision:s,generation:n},i);return await this.listWorkItems(i,this._workCenterListFiltersByAgent[i]||{}),this.commitWorkCenterDetail(i,a,o),a},async sendWorkItemActionInput(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=Number(this._workCenterActionInputGenerationByAgent[a]||0)+1;this._workCenterActionInputGenerationByAgent={...this._workCenterActionInputGenerationByAgent,[a]:l};let c=await this.workCenterRequest("action_input",{id:e,text:t,actionId:s,revision:n,generation:r,attachments:i},a);await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{});let d=this.workCenterDetailByAgent[a],u=d?.actions?.find(p=>p?.id===s),f=d?.id===e&&Number(d.revision)===Number(n)&&u&&Number(u.generation)===Number(r);return this._workCenterActionInputGenerationByAgent[a]===l&&f&&!Dd(c,d)?(this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[a]:c},c):d?.id===e?d:c},async guideWorkItemAction(e,t,s,n,r,i=[],o=null){let a=o||this.workCenterAgentId||this.currentAgent,l=this.beginWorkCenterDetailWrite(a),c=await this.workCenterRequest("guide",{id:e,guidance:t,actionId:s,revision:n,generation:r,attachments:i},a);return await this.listWorkItems(a,this._workCenterListFiltersByAgent[a]||{}),this.commitWorkCenterDetail(a,c,l),c},previewWorkItemAttachment(e,t,s=null){let n=s||this.workCenterAgentId||this.currentAgent;return this.workCenterRequest("preview_attachment",{id:e,attachmentId:t},n)},applyWorkCenterEvent(e,t){if(!e||!t?.workItem)return;let s=t.workItem;if(t.clientMessageId){this.confirmWorkCenterMessageEnvelope(e,s.id,t.clientMessageId);let u=Object.entries(this.workCenterPending||{}).find(([,f])=>f?.agentId===e&&f.clientMessageId===t.clientMessageId);if(u){let[f,p]=u;clearTimeout(p.timer),delete this.workCenterPending[f],p.resolve(t.type==="coordinator.turn_started"?{accepted:!0,turnId:null,receipt:!0}:t.workItem)}}let n=this.workCenterItemsByAgent[e]||[];if(t.type==="work_item.deleted"){this.removeWorkItemState(e,s.id);return}if(this.workItemDeleted(e,s.id))return;let r=this._workCenterListFiltersByAgent[e]||{},i=this._workCenterListEventsByAgent[e]?.[s.id]?.summary||null,o=n.some(u=>u?.id===s.id)?n:i?[i]:[],a=Er(o,s).find(u=>u?.id===s.id)||s,l=Number(this._workCenterListEventGenerationByAgent[e]||0)+1;this._workCenterListEventGenerationByAgent={...this._workCenterListEventGenerationByAgent,[e]:l},this._workCenterListEventsByAgent={...this._workCenterListEventsByAgent,[e]:{...this._workCenterListEventsByAgent[e]||{},[s.id]:{generation:l,queryKey:this._workCenterListQueryByAgent[e]||null,summary:a}}};let c=this.applyWorkItemBoardSummary(n,a,r);this.workCenterItemsByAgent={...this.workCenterItemsByAgent,[e]:c};let d=this.workCenterDetailByAgent[e];if(d?.id===s.id){let u=t.type==="run.finished"&&t.actionId&&Array.isArray(s.actionStats)&&s.actionStats.some(A=>A?.id===t.actionId)?{...s,eventActionId:t.actionId}:s,f=zo(d,u),p=Number(s.coordinatorRevision),g=Number(d.coordinatorRevision)||0,b=Number.isInteger(p)&&p>g,h=Ld(d,u);this.workCenterDetailByAgent={...this.workCenterDetailByAgent,[e]:$d(d,s)},h&&this.refreshWorkItemDetailAfterActionChange(e,s,b?null:f)}},async refreshWorkItemDetailAfterActionChange(e,t,s=null){let n=s?(Array.isArray(t.actionStats)?t.actionStats:[]).find(b=>b?.id===s.actionId):(Array.isArray(t.actionStats)?t.actionStats:[]).find(b=>b?.id===t.currentActionId)||t.currentAction,r=s?.actionId||t.currentActionId||null,i=Number(s?.generation??n?.generation),o=Number.isInteger(i)&&i>0?i:null,a=Number(t.coordinatorRevision),l=!s&&Number.isInteger(a)&&a>=0?a:null,c=Number(s?.attempt),d=Number.isInteger(c)&&c>=0?c:null,u=l!=null?`${t.id}:coordinator:${l}`:`${t.id}:${r}${o==null?"":`:${o}`}${d==null?"":`:${d}`}`;if(this._workCenterDetailEventRefreshByAgent[e]?.key===u)return;let f=this.beginWorkCenterDetailWrite(e),p={key:u,generation:f};this._workCenterDetailEventRefreshByAgent={...this._workCenterDetailEventRefreshByAgent,[e]:p},s&&this.invalidateWorkItemActionMessages(e,t.id,s.actionId,s.generation);let g=r&&o!=null?this.loadWorkItemActionMessages(t.id,r,o,null,e).catch(()=>null):null;try{let b=await this.workCenterRequest("get",{id:t.id},e),h=this.workCenterDetailByAgent[e],A=h?.actions?.find(E=>E?.id===r),w=b?.actions?.find(E=>E?.id===r),S=o==null||tt(A?.generation)===o,y=o==null||tt(w?.generation)>=o,m=l==null||Number(b?.coordinatorRevision)===l,v=l!=null||S&&y&&(t.currentActionId==null?b?.currentActionId==null:h?.currentActionId===t.currentActionId&&b?.currentActionId===t.currentActionId);h?.id===t.id&&m&&v&&this.commitWorkCenterDetail(e,b,f)&&g&&await g}catch{}finally{if(this._workCenterDetailEventRefreshByAgent[e]===p){let b={...this._workCenterDetailEventRefreshByAgent};delete b[e],this._workCenterDetailEventRefreshByAgent=b}}},cacheYeaftAgentStatus(e,t,{allowBootstrapCatalog:s=!1}={}){if(!e||!t)return;let n=this.yeaftStatusByAgent[e]||{},r=Number(n.catalogRevision)||0,i=Number(t.catalogRevision)||0,o=typeof n.catalogEpoch=="string"?n.catalogEpoch:"",a=typeof t.catalogEpoch=="string"?t.catalogEpoch:"",l=Number(n.catalogRefreshedAt)||0,c=Number(t.catalogRefreshedAt)||0,d=Array.isArray(t.availableModels),u=t.type==="yeaft_status"&&d&&(i>0||c>0),f=Array.isArray(this._yeaftRetiredCatalogEpochsByAgent?.[e])?this._yeaftRetiredCatalogEpochsByAgent[e]:[],p=!!a&&f.includes(a),g=!!a&&a===o,b=i>0?g&&i===r:c>0&&c===l,h=i>0?!!a&&(a!==o||i>r):r===0&&c>l,A=i>0?!!t.catalogDigest&&!!n.catalogDigest&&t.catalogDigest===n.catalogDigest:t.catalogDigest===n.catalogDigest,w=u&&!p&&(h||b&&A),y=w||s&&r===0&&l===0&&!u&&d,m={...t};if(!y)for(let E of Rh)delete m[E];let v={...n,...m};if(y){if(w&&o&&a&&o!==a){let E=[...f.filter(V=>V!==o),o].slice(-_h);this._yeaftRetiredCatalogEpochsByAgent={...this._yeaftRetiredCatalogEpochsByAgent||{},[e]:E}}v.availableModels=t.availableModels,v.catalogRefreshedAt=w?c:null,v.catalogEpoch=w&&a||null,v.catalogRevision=w&&i||null,v.catalogDigest=w&&t.catalogDigest||null}this.yeaftStatusByAgent={...this.yeaftStatusByAgent,[e]:v},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 Ie(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))},Mh),e):(this.yeaftSessionHydrateRequestId=null,this.yeaftSessionHydrateSlices=[],this.yeaftSessionHydrateError="session_inventory_send_failed",null)},beginYeaftHistoryLoad(e){let t=vc(this,e);if(!t)return null;let{agentId:s,sessionId:n}=e||{};return setTimeout(()=>{bc(this,{agentId:s,sessionId:n,requestId:t.requestId,error:"history_load_timeout"})},hc),t},finishYeaftHistoryLoad(e,t={},s="chunk"){return yc(this,e,t,s)},isCurrentYeaftHistoryResponse(e){return Po(this,e)},syncActiveYeaftHistoryLoad(){return Tn(this)},enterYeaft(e=null,{deferBootstrap:t=!1}={}){let s=this.currentAgent;Bo(this);let n=us(this),r=!e&&n?Ie(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]=[]),Sd(this),this.currentView="yeaft",No("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=us(this),r=n?Ie(this,n):this.currentAgent,i=Pe(r,n),o=n?this.yeaftSessionHistoryState[i]:null,a=e||!this.yeaftSessionReady||!this.yeaftModel||!this.yeaftStatus,l=Number.isFinite(o?.latestSeq)?o.latestSeq:null,c=!!n&&!!this.yeaftConversationId&&Array.isArray(this.messagesMap?.[this.yeaftConversationId])&&this.messagesMap[this.yeaftConversationId].some(w=>w&&(w.sessionId??w.groupId??null)===n),d=!!n&&bo({sessionState:o,hasCachedSessionRows:c,force:!!s}),u=!!n&&!d&&ac(o,t);if(!a&&!d&&!u)return!1;let f=`${r}:${n||"__none__"}`,p=a&&!d&&!u;if(p&&this.yeaftBootstrapMetaLoadingKey===f)return!1;p&&(this.yeaftBootstrapMetaLoadingKey=f);let g=null;n&&d?g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1}):n&&c&&!o?.loaded?(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[i]:{...o||{},loaded:!0,loading:!1,hasMore:!!o?.hasMore,oldestSeq:Number.isFinite(o?.oldestSeq)?o.oldestSeq:null,count:o?.count||0,latestSeq:l}},this.yeaftLoadingMoreHistory=!1):n&&u&&(g=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:l}));let b={type:"yeaft_load_history",agentId:r,sessionId:n,...g?{requestId:g.requestId}:{}};u?b.afterSeq=l:b.limit=d?Or:0;let h=An();b.perfTraceId=h;let A=u?"delta":d?"recent":"metadata";return n&&(this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[i]:h}),Xe(this,{traceId:h,phase:"history.request_send",agentId:r,sessionId:n,messageType:b.type,bytes:JSON.stringify(b).length,detail:{mode:A,limit:b.limit??null,afterSeq:b.afterSeq??null,hasCachedSessionRows:c,needSessionReady:a}}),this.sendWsMessage(b),!0},leaveYeaft(){this.activateChatView({persistPreference:!0})},fetchYeaftToolStats(){this.currentAgent&&(this.yeaftToolStatsLoading=!0,this.sendWsMessage({type:"yeaft_fetch_tool_stats",agentId:this.currentAgent}),this._fetchYeaftToolStatsTimer&&clearTimeout(this._fetchYeaftToolStatsTimer),this._fetchYeaftToolStatsTimer=setTimeout(()=>{this.yeaftToolStatsLoading&&(this.yeaftToolStatsLoading=!1,this.yeaftToolStats={...this.yeaftToolStats||{snapshot:{},registered:[],unused:[]},error:null,notice:"Tool stats are unavailable right now. Try again after the agent reconnects.",fetchedAt:Date.now()}),this._fetchYeaftToolStatsTimer=null},1e4))},loadYeaftDebugHistory({groupId:e,limit:t,dreamLimit:s,indexOnly:n=!1,detailTurnId:r=null,search:i=void 0}={}){if(!this.currentAgent)return;let o=typeof i=="string"?i.trim():(this.yeaftDebugSearch||"").trim(),a=typeof r=="string"&&r,l=o&&!a?iu:sa,c=Number.isFinite(t)&&t>0?t:this.yeaftDebugHistoryLimit||l,d=Math.max(1,Math.min(l,c)),u=a?"detail":"list",f=`dbg_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,p=JSON.stringify({agentId:this.currentAgent,groupId:e||null,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5,indexOnly:!!n,detailTurnId:r||null,search:a?"":o});if(this._yeaftDebugHistoryInFlightKey===p)return;this._yeaftDebugHistoryInFlightKey=p,a||(this._yeaftDebugHistoryLatestListRequestId=f),this.yeaftDebugHistoryLimit=d,this.yeaftDebugHistoryLoading=!0,this.yeaftDebugHistoryError=null;let g={type:"yeaft_fetch_debug_history",agentId:this.currentAgent,requestId:f,requestKind:u,limit:d,dreamLimit:Number.isFinite(s)&&s>0?s:5};n&&(g.indexOnly=!0),typeof r=="string"&&r?g.detailTurnId=r:o&&(g.search=o),typeof e=="string"&&e&&(g.sessionId=e),this.sendWsMessage(g),this._fetchYeaftDebugHistoryTimer&&clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=setTimeout(()=>{this.yeaftDebugHistoryLoading&&(this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError="Debug history is unavailable right now. Try again after the agent reconnects."),this._yeaftDebugHistoryInFlightKey=null,this._fetchYeaftDebugHistoryTimer=null},1e4)},agentIdForSession(e){return Ie(this,e)},sendYeaftSessionMessage({groupId:e,text:t,mentions:s,attachments:n,quote:r}){let i=Ie(this,e);if(!e||!i)return;let o=Array.isArray(n)?n.filter(g=>g&&g.fileId):[],a=Dr(r),l=o.length>0;if(!t?.trim()&&!l)return;let c=t?.trim()?t:"(attached files)",d=`u_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,10)}`,u=An();this.yeaftPerfTraceByMessageId={...this.yeaftPerfTraceByMessageId||{},[d]:u},Xe(this,{traceId:u,phase:"send.prepare",agentId:i,sessionId:e,turnId:d,messageType:"yeaft_session_send",detail:{mentionCount:Array.isArray(s)?s.length:0,attachmentCount:o.length,quoted:!!a}});let f=Mt(this,e);if(f){let g={id:d,messageId:d,clientMessageId:d,type:"user",content:c,sessionId:e,turnId:d,...a?{quote:a}:{}};if(o.length>0&&(g.attachments=o.map(b=>({fileId:b.fileId,name:b.name,preview:b.preview,isImage:!!b.isImage,mimeType:b.mimeType||""}))),this.addMessageToConversation(f,g),this.processingConversations[f]=!0,e){let b=dt(i,e);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...b?{[b]:!0}:{}}}this._turnCompletedConvs?.delete(f),this._closedAt?.[f]&&delete this._closedAt[f],this.getOrCreateExecutionStatus(f),kn(this,f)}let p={type:"yeaft_session_send",agentId:i,id:d,sessionId:e,text:c,mentions:Array.isArray(s)?s:[],perfTraceId:u,...a?{quote:a}:{}};o.length>0&&(p.attachments=o.map(g=>({fileId:g.fileId,isImage:!!g.isImage}))),Xe(this,{traceId:u,phase:"send.websocket_send",agentId:i,sessionId:e,turnId:d,messageType:p.type,bytes:JSON.stringify(p).length}),this.sendWsMessage(p)},cancelYeaftTask({agentId:e=null,sessionId:t,taskId:s}){let n=typeof t=="string"?t.trim():"",r=typeof s=="string"?s.trim():"",i=Ie(this,n,e);return!i||!n||!r?!1:(this.yeaftStoppingTasksById={...this.yeaftStoppingTasksById,[ea(i,n,r)]:!0},this.sendWsMessage({type:"yeaft_task_cancel",agentId:i,sessionId:n,taskId:r,clientRequestId:`task_cancel_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}),!0)},getYeaftMessageWindowKey(e=null){return e||this.yeaftActiveSessionFilter||"__all__"},pruneYeaftMessageWindow(e=null){if(this.currentView!=="yeaft")return;let t=this.getYeaftMessageWindowKey(e);this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[t]:{visibleTurns:ds()}}},expandYeaftMessageWindow(e=null,t=Ln()){if(this.currentView!=="yeaft")return;let s=this.getYeaftMessageWindowKey(e),r=(this.yeaftMessageWindowState[s]?.visibleTurns||ds())+Math.max(1,Number.isFinite(t)?Math.floor(t):Ln());this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[s]:{visibleTurns:r}}},isYeaftMessageCached(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Mt(this,n);return!r||!t?!1:(this.messagesMap[r]||[]).some(i=>(!n||(i?.sessionId??i?.groupId??null)===n)&&((i?.id||i?.messageId)===t||i?.persistedMessageId===t))},revealYeaftMessage(e,t,s=null){let n=e||this.yeaftActiveSessionFilter||null,r=s||Mt(this,n);if(!r||!t)return!1;let i=(this.messagesMap[r]||[]).filter(u=>n?(u?.sessionId??u?.groupId??null)===n:!0),o=i.findIndex(u=>(u?.id||u?.messageId)===t||u?.persistedMessageId===t);if(o<0)return!1;let a=Ud(i),l=a.findIndex(u=>o>=u.start&&o<u.end);if(l<0)return!1;let c=Math.max(ds(),a.length-l),d=this.getYeaftMessageWindowKey(n);return this.yeaftMessageWindowState={...this.yeaftMessageWindowState,[d]:{visibleTurns:c}},!0},getYeaftHistoryOutlineState(e=null,t=null){let s=e||this.yeaftActiveSessionFilter||null,n=Ie(this,s,t),r=Pe(n,s),i=this.yeaftHistoryOutlineBySession[r]||{requestId:null,agentId:n,sessionId:s,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,totalCount:null,loaded:!1,error:null},o=Mt(this,s),a=o?this.messagesMap[o]||[]:[],l=new Map((i.results||[]).map(f=>[$n(f),f])),c=0;for(let f of a){if((f?.sessionId??f?.groupId??null)!==s)continue;let p=f.messageId||f.id;if(!p)continue;let g=f.type==="user"&&!!f.clientMessageId&&p===f.clientMessageId,b=f.type==="assistant"&&f.isStreaming===!0;if(!g&&!b)continue;let h=f.type,A=f.turnId||f.threadId||p,w=f.speakerVpId||f.vpId||null,S=$n({role:h,messageId:p,clientMessageId:f.clientMessageId,turnId:A,speakerVpId:w}),y=l.get(S),v=(typeof f.content=="string"?f.content:"").replace(/\s+/g," ").trim();l.set(S,{...y,messageId:Number.isFinite(y?.seq)?y.messageId:p,...f.clientMessageId?{clientMessageId:f.clientMessageId}:{},turnId:A,role:h,speakerVpId:w||y?.speakerVpId||null,timestamp:f.timestamp||f.ts||y?.timestamp||null,snippet:v.length>180?`${v.slice(0,180).trimEnd()}\u2026`:v||y?.snippet||""}),y||(c+=1)}let d=f=>{let p=typeof f=="number"?f:Date.parse(f||"");return Number.isFinite(p)?p:0},u=Array.from(l.values()).sort((f,p)=>Number.isFinite(f.seq)&&Number.isFinite(p.seq)?f.seq-p.seq:d(f.timestamp)-d(p.timestamp));return{...i,results:u,totalCount:Number.isFinite(i.totalCount)?i.totalCount+c:i.totalCount}},promoteYeaftHistoryOutlineRow(e){let t=e?.sessionId??e?.groupId??null,s=Ie(this,t),n=Pe(s,t),r=this.yeaftHistoryOutlineBySession[n];if(!t||!s||!r?.loaded||r.loading)return!1;let i=e?.type;if(i!=="user"&&i!=="assistant")return!1;let o=e.dbMessageId||e.messageId||e.id||null,a=Hh(o);if(!o||!Number.isFinite(a))return!1;let l=e.turnId||e.threadId||o,c=e.speakerVpId||e.vpId||null,u=(typeof e.content=="string"?e.content:"").replace(/\s+/g," ").trim(),f=$n({role:i,messageId:o,clientMessageId:e.clientMessageId,turnId:l,speakerVpId:c}),p=new Map((r.results||[]).map(S=>[$n(S),S])),g=p.get(f);p.set(f,{...g,messageId:o,...e.clientMessageId?{clientMessageId:e.clientMessageId}:{},turnId:l,seq:a,role:i,speakerVpId:c,timestamp:e.timestamp||e.ts||g?.timestamp||null,snippet:u.length>180?`${u.slice(0,180).trimEnd()}\u2026`:u||g?.snippet||""});let b=50,h=Array.from(p.values()).sort((S,y)=>(S.seq||0)-(y.seq||0)),A=h.length>b,w=h.slice(-b);return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[n]:{...r,results:w,hasMore:r.hasMore||A,nextBeforeSeq:A&&Number.isFinite(w[0]?.seq)?w[0].seq:r.nextBeforeSeq,totalCount:Number.isFinite(r.totalCount)&&!g?r.totalCount+1:r.totalCount}},!0},promoteCompletedYeaftHistoryOutline(e,t=null){let s=this.messagesMap[e]||[],n=null,r=[];for(let i=s.length-1;i>=0;i--){let o=s[i];if(o?.type==="user")break;if(t&&o?.turnId&&o.turnId!==t||o?.type!=="assistant")continue;let a=typeof o.content=="string"?o.content.replace(/\s+/g," ").trim():"";n?!String(n.content||"").trim()&&a&&(n=o):n=o,a&&r.unshift(a)}return n?this.promoteYeaftHistoryOutlineRow({...n,content:r.join(" ")}):!1},invalidateYeaftHistoryOutline(e){let t=Ie(this,e),s=Pe(t,e),n=this.yeaftHistoryOutlineBySession[s];return!e||!t||!n?!1:n.loading?(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,refreshPending:!0}},!0):(this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[s]:{...n,loaded:!1,refreshPending:!1}},this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e?this.loadYeaftHistoryOutline({force:!0}):!0)},loadYeaftHistoryOutline({append:e=!1,force:t=!1,targetSessionId:s=null,targetAgentId:n=null}={}){if(this.currentView!=="yeaft"&&!s)return!1;let r=s||this.yeaftActiveSessionFilter||null,i=n||Ie(this,r);if(!r||!i)return!1;let o=Pe(i,r),a=this.getYeaftHistoryOutlineState(r,i);if(!e&&a.loaded&&!t)return!0;if(e&&(!a.hasMore||!Number.isFinite(a.nextBeforeSeq))||a.loading)return!1;if(!su(this,i,"session_history_outline"))return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...a,error:"unsupported",loading:!1}},!1;let l=`history_outline_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,c={...a,requestId:l,agentId:i,sessionId:r,loading:!0,requestAppend:e,refreshPending:!1,error:null};this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:c};let d=this._yeaftHistoryOutlineTimeouts[o];d&&clearTimeout(d);let u=setTimeout(()=>{let f=this.yeaftHistoryOutlineBySession[o];if(f?.requestId!==l)return;let p={...this._yeaftHistoryOutlineTimeouts};delete p[o],this._yeaftHistoryOutlineTimeouts=p;let g=f.refreshPending===!0;this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[o]:{...f,requestId:null,loading:!1,requestAppend:!1,loaded:g?!1:f.loaded,refreshPending:!1,error:g?null:"timeout"}},g&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:r,targetAgentId:i})},1e4);return this._yeaftHistoryOutlineTimeouts={...this._yeaftHistoryOutlineTimeouts,[o]:u},this.sendWsMessage({type:"yeaft_load_history_outline",agentId:i,sessionId:r,requestId:l,limit:50,...e&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{},includeTotal:!a.loaded}),!0},handleYeaftHistoryOutline(e){if(!e?.agentId||!e?.sessionId)return!1;let t=Pe(e.agentId,e.sessionId),s=this.yeaftHistoryOutlineBySession[t];if(!s||e.requestId!==s.requestId)return!1;let n=this._yeaftHistoryOutlineTimeouts[t];n&&clearTimeout(n);let r={...this._yeaftHistoryOutlineTimeouts};delete r[t],this._yeaftHistoryOutlineTimeouts=r;let i=Array.isArray(e.results)?e.results:[],o=s.requestAppend?[...s.results||[],...i]:i,a=new Map(o.filter(d=>d?.messageId).map(d=>[$n(d),d])),l=Array.from(a.values()).sort((d,u)=>(d.seq||0)-(u.seq||0)),c=s.refreshPending===!0;return this.yeaftHistoryOutlineBySession={...this.yeaftHistoryOutlineBySession,[t]:{...s,requestId:null,loading:!1,requestAppend:!1,refreshPending:!1,loaded:c?!1:!e.error,results:l,hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,totalCount:Number.isFinite(e.totalCount)?e.totalCount:s.totalCount,error:c?null:e.error||null}},c&&this.loadYeaftHistoryOutline({force:!0,targetSessionId:e.sessionId,targetAgentId:e.agentId}),!0},searchYeaftHistory(e,{append:t=!1,senderKey:s=""}={}){if(this.currentView!=="yeaft")return!1;let n=typeof e=="string"?e.trim():"",r=typeof s=="string"&&(s==="user"||s.startsWith("vp:"))?s.slice(0,103):"",i=this.yeaftActiveSessionFilter||null,o=Ie(this,i);if(this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null),!i||!o||n.length<2&&!r)return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null},!1;let a=this.yeaftHistorySearchState||{};if(!su(this,o,"session_history_search"))return this.yeaftHistorySearchState={requestId:null,agentId:o,sessionId:i,query:n,senderKey:r,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:"unsupported"},!1;let l=`history_search_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return this.yeaftHistorySearchState={requestId:l,agentId:o,sessionId:i,query:n,senderKey:r,loading:!0,results:t&&a.query===n&&a.senderKey===r?a.results:[],hasMore:!1,nextBeforeSeq:t&&a.query===n&&a.senderKey===r?a.nextBeforeSeq:null,error:null},this._yeaftHistorySearchTimeout=setTimeout(()=>{this.yeaftHistorySearchState?.requestId===l&&(this._yeaftHistorySearchTimeout=null,this.yeaftHistorySearchState={...this.yeaftHistorySearchState,loading:!1,error:"timeout"})},1e4),this.sendWsMessage({type:"yeaft_search_history",agentId:o,sessionId:i,requestId:l,query:n,senderKey:r,limit:20,...t&&a.query===n&&a.senderKey===r&&Number.isFinite(a.nextBeforeSeq)?{beforeSeq:a.nextBeforeSeq}:{}}),!0},handleYeaftHistorySearchResult(e){let t=this.yeaftHistorySearchState||{};if(!e||e.requestId!==t.requestId||e.agentId!==t.agentId||e.sessionId!==t.sessionId||e.query!==t.query||(e.senderKey||"")!==t.senderKey)return!1;this._yeaftHistorySearchTimeout&&(clearTimeout(this._yeaftHistorySearchTimeout),this._yeaftHistorySearchTimeout=null);let s=Array.isArray(e.results)?e.results:[],n=new Map((t.results||[]).map(r=>[r.messageId,r]));for(let r of s)r?.messageId&&n.set(r.messageId,r);return this.yeaftHistorySearchState={...t,loading:!1,results:Array.from(n.values()),hasMore:!!e.hasMore,nextBeforeSeq:Number.isFinite(e.nextBeforeSeq)?e.nextBeforeSeq:null,error:e.error||null},!0},loadYeaftHistoryWindow(e){let t=this.yeaftActiveSessionFilter||null,s=Ie(this,t);if(!t||!s||!e?.messageId||!Number.isFinite(e.seq))return Promise.resolve(!1);if(this.isYeaftMessageCached(t,e.messageId))return Promise.resolve(!0);let n=Pe(s,`${t}:${e.messageId}`),r=this._yeaftHistoryWindowPendingByKey||{};if(r[n]?.promise)return r[n].promise;let i=`history_window_${Date.now()}_${Math.random().toString(36).slice(2,8)}`,o=null,a=new Promise(c=>{o=c}),l=setTimeout(()=>{if(this._yeaftHistoryWindowPendingByKey?.[n]?.requestId!==i)return;let{[n]:d,...u}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=u,o(!1)},1e4);return this._yeaftHistoryWindowPendingByKey={...r,[n]:{requestId:i,agentId:s,sessionId:t,messageId:e.messageId,resolve:o,timeout:l,promise:a}},this.sendWsMessage({type:"yeaft_load_history_window",agentId:s,sessionId:t,requestId:i,anchorMessageId:e.messageId,anchorSeq:e.seq,beforeTurns:5,afterTurns:5}),a},async revealYeaftHistoryResult(e){let t=this.yeaftActiveSessionFilter||null,s=Ie(this,t),n=Mt(this,t);return!t||!s||!n||!e?.messageId||!await this.loadYeaftHistoryWindow(e)||this.currentView!=="yeaft"||this.yeaftActiveSessionFilter!==t||Ie(this,t)!==s||Mt(this,t)!==n?!1:this.revealYeaftMessage(t,e.messageId,n)},handleYeaftHistoryWindow(e,t=null){let n=Object.entries(this._yeaftHistoryWindowPendingByKey||{}).find(([,c])=>c?.requestId===e?.requestId);if(!n)return!1;let[r,i]=n;if(e.agentId!==i.agentId||e.sessionId!==i.sessionId)return!1;clearTimeout(i.timeout);let{[r]:o,...a}=this._yeaftHistoryWindowPendingByKey;this._yeaftHistoryWindowPendingByKey=a;let l=!e.error&&!!t&&this.isYeaftMessageCached(i.sessionId,i.messageId,t);return i.resolve(!!l),!!l},createYeaftSession({displayName:e,vpIds:t,defaultVpId:s,workDir:n,agentId:r}={}){let i=Array.isArray(t)?t.slice():[],o=s&&i.includes(s)?s:i[0]||null,a=(e||"").trim(),l=(n||"").trim(),c={roster:i,defaultVpId:o};return a&&(c.name=a),l&&(c.workDir=l),this.sessionCrudRequest("create",c,{agentId:r})},handleYeaftOutput(e){if(!e)return;let t=e.agentId||this.yeaftAgentId||this.currentAgent||null,s=e.conversationId||e.event?.conversationId||null,n=$s(this,t,s);if(e.data&&n){if(e.data.type!=="result")return;let i=mc(this,t,s);if(!i)return;let o=e.turnId?Bs(this,t,e.turnId):"",a=!!(o&&this.activeVpTurns?.[o])||(this.messagesMap?.[i]||[]).some(l=>l?.turnId===e.turnId&&(l.isStreaming||l.status==="pending"));if(!e.turnId||!a)return;e={...e,conversationId:i}}if(e.perfTraceId&&(Xe(this,{traceId:e.perfTraceId,phase:"receive.yeaft_output",agentId:e.agentId||null,sessionId:e.sessionId||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||e.event?.type||e.type}),e.turnId&&(this.yeaftPerfTraceByTurnId={...this.yeaftPerfTraceByTurnId||{},[e.turnId]:e.perfTraceId})),e.data){let i=e.agentId||this.yeaftAgentId||this.currentAgent||null,o=Wt(this,i,e.conversationId),a=e.turnId?Bs(this,e.agentId||null,e.turnId):"";if(a&&this.activeVpTurns?.[a]?.retryAttempt){let{retryAttempt:l,retryMax:c,retryDelayMs:d,retryReason:u,retryRecoveryMode:f,...p}=this.activeVpTurns[a];this.activeVpTurns={...this.activeVpTurns,[a]:p}}if(o){let l=e.sessionId??e.groupId??null,c=nu(this,l,i),d=i&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[i]:null,u=mt(this,i);u&&u.targetConversationId!==o?Cn(this,i,o):!u&&d&&d!==o&&!String(d).startsWith("yeaft-local-")&&(ht(this,d,o,{removeSource:d!==this.yeaftConversationId}),Sn(this,i,d,o)),Io(this,i,o);let f=mt(this,i,o),p=f?.sourceConversationId||d,g=!c&&p===this.yeaftConversationId;if(this.currentView==="yeaft"&&i&&p&&p!==o){let y=!g&&(!!f||String(p).startsWith("yeaft-local-"));ht(this,p,o,{removeSource:y}),g?Cr(this,i,p,o):y&&In(this,i,o)}i&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[i]:o}),(c||!this.yeaftConversationId)&&(this.yeaftConversationId=o),c&&(this.activeConversations=[o]),this.messagesMap[o]||(this.messagesMap[o]=[]),this.currentView==="yeaft"&&(e.data?.type==="user"||e.data?.type==="text_delta")&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter&&e.sessionId||null);let b=this._currentYeaftAgentId,h=this._currentYeaftSessionId,A=this._currentYeaftVpId,w=this._currentYeaftTurnId,S=this._currentYeaftThreadId;i&&(this._currentYeaftAgentId=i),l!=null&&(this._currentYeaftSessionId=l),e.vpId&&(this._currentYeaftVpId=e.vpId),e.turnId&&(this._currentYeaftTurnId=e.turnId),e.threadId&&(this._currentYeaftThreadId=e.threadId);try{this.currentView==="yeaft"&&l&&(!this.yeaftActiveSessionFilter||l===this.yeaftActiveSessionFilter)&&this.pruneYeaftMessageWindow(this.yeaftActiveSessionFilter?l:null);let m=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();if(this.handleAssistantOutputFrame(o,e.data),e.perfTraceId){let M=typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();Xe(this,{traceId:e.perfTraceId,phase:"store.apply_output",agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null,durationMs:M-m}),xr(this,{traceId:e.perfTraceId,agentId:e.agentId||null,sessionId:l||null,vpId:e.vpId||null,turnId:e.turnId||null,threadId:e.threadId||null,messageType:e.data?.type||null})}let v=e.data,E=v?.message?.id||v?.id||null,V=Oh(E),U=Array.isArray(v?.message?.content)?v.message.content:[],L=U.some(M=>M?.type==="tool_use"),D=!!v?.tool_use_result||U.some(M=>M?.type==="tool_result");if(l){let M=!D&&!Fh(this,o,l)&&(v?.type==="user"||v?.type==="assistant"&&!L)?V:null,T=Pe(e.agentId||null,l),C=this.yeaftSessionHistoryState[T]||{},R=Number.isFinite(C.latestSeq)?C.latestSeq:-1;M!==null&&M>R&&(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[T]:{...C,latestSeq:M}})}}finally{this._currentYeaftAgentId=b,this._currentYeaftSessionId=h,this._currentYeaftVpId=A,this._currentYeaftTurnId=w,this._currentYeaftThreadId=S}}return}let r=e.event;if(r)switch(r.type){case"project_mutation_result":r.projectsAuthoritative===!0?this.finishProjectMutation(r):this.finishLegacyProjectMutation(r,e.agentId||null);break;case"ask_user_question":{let i=Wt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=Xd(e,r,i),a=()=>{let l=this.messagesMap[i]||[],c=Jd(l,o,i);if(c){if(c.askAnswered||c.askExpired)return!0;c.toolName="AskUserQuestion",r.toolCallId&&!c.toolId&&(c.toolId=r.toolCallId),c.agentId=o.agentId||c.agentId||null,c.askRequestId=r.requestId,c.askQuestions=r.questions||[],c.askCreatedAt=r.createdAt||null,c.askExpiresAt=r.expiresAt||null,r.replay&&(c.askPending=!1,c.pendingAnswers=null,c.askSubmitGeneration=null),c.isHistory=!1;let f=eu(this,o);return f&&Jo(c,f),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0}if(!r.replay)return!1;let d={id:`ask-card-${r.requestId}`,type:"tool-use",toolName:"AskUserQuestion",toolId:r.toolCallId||null,toolInput:{questions:r.questions||[]},askRequestId:r.requestId,askQuestions:r.questions||[],askCreatedAt:r.createdAt||null,askExpiresAt:r.expiresAt||null,agentId:o.agentId,sessionId:o.sessionId,vpId:o.vpId,speakerVpId:o.vpId,turnId:o.turnId,threadId:o.threadId||"main",hasResult:!1,isHistory:!1,timestamp:r.createdAt||Date.now()},u=eu(this,o);return u&&Jo(d,u),l.push(d),this.messagesMap={...this.messagesMap,[i]:l.slice()},!0};if(!a()){let l=0,c=setInterval(()=>{l+=1,(a()||l>=10)&&clearInterval(c)},200)}break}case"ask_user_answered":case"ask_user_expired":{let i=Wt(this,e.agentId||null,e.conversationId);if(!i||!r.requestId)break;let o=this.messagesMap[i]||[],a=Xd(e,r,i),l=Jd(o,a,i);if(!l){Vh(this,a,r);break}Jo(l,r),this.messagesMap={...this.messagesMap,[i]:o.slice()};break}case"session_ready":{let i=r.conversationId,o=e.agentId||this.currentAgent;if($s(this,o,i))break;let a=o&&this.yeaftConversationIdsByAgent?this.yeaftConversationIdsByAgent[o]:null,l=this.yeaftConversationId?String(this.yeaftConversationId):"",c=l.startsWith("yeaft-local-")&&(!o||l.startsWith(`yeaft-local-${o}-`)||/^yeaft-local-\d/.test(l))?this.yeaftConversationId:null,d=a||c,u=r.sessionId||e.sessionId||null,f=nu(this,u,o),p=mt(this,o);p&&p.targetConversationId!==i?Cn(this,o,i):!p&&a&&a!==i&&!String(a).startsWith("yeaft-local-")&&Sn(this,o,a,i),Io(this,o,i);let b=mt(this,o,i)?.sourceConversationId||d,h=!f&&b===this.yeaftConversationId;if(b&&b!==i){let m=!h;ht(this,b,i,{removeSource:m}),h?Cr(this,o,b,i):m&&In(this,o,i)}else this.messagesMap[i]||(this.messagesMap[i]=[]);o&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[o]:i},this.cacheYeaftAgentStatus(o,r,{allowBootstrapCatalog:f})),f&&(this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null,this.yeaftSessionReady=!0,this.yeaftBootstrapMetaLoadingKey=null,o?this.applyCachedYeaftStatus(o):this.yeaftAvailableModels=r.availableModels||[]);let A=Array.isArray(r.tasks)?r.tasks:[],w={};for(let[m,v]of Object.entries(this.yeaftActiveTasksBySession||{})){let E=Object.fromEntries(Object.entries(v||{}).filter(([,U])=>U?.id&&(U.agentId&&U.agentId!==o||na.has(U.status)))),V=ta(E);Object.keys(V).length>0&&(w[m]=V)}for(let m of A){if(!m?.id||!m.sessionId||m.status!=="running")continue;let v=Pe(o,m.sessionId);w[v]={...w[v]||{},[m.id]:{...m,agentId:o}}}this.yeaftActiveTasksBySession=w,f&&(r.yeaftDir&&(this.yeaftYeaftDir=r.yeaftDir),this.yeaftStatus={skills:r.skills,mcpServers:r.mcpServers,tools:r.tools,multiVp:!!r.multiVp}),(f||!this.yeaftConversationId)&&(this.yeaftConversationId=i),f&&(this.activeConversations=[i]);let S=e.agentId||this.currentAgent||null,y=S||"__current__";this._yeaftVpSubscribedAgentKey!==y&&(this._yeaftVpSubscribedAgentKey=y,this.sendWsMessage(S?{type:"yeaft_vp_subscribe",agentId:S}:{type:"yeaft_vp_subscribe"}));break}case"yeaft_status":{let i=e.agentId||this.currentAgent;i&&this.cacheYeaftAgentStatus(i,r);break}case"context_usage":break;case"turn_open":{if(!r.turnId)break;let i={turnId:r.turnId,userPrompt:r.userPrompt||"",vpId:r.vpId||e.vpId||null,sessionId:r.sessionId||e.sessionId||null,openedAt:r.at||Date.now(),closedAt:null,totalMs:0,totalTokens:0,loopCount:0,memoryLoaded:null,memoryLoadedMeta:null,memoryAdjust:null,tools:[],detailsLoaded:!0};this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:i},this.yeaftDebugTurnOrder.includes(r.turnId)||(this.yeaftDebugTurnOrder=[...this.yeaftDebugTurnOrder,r.turnId]);break}case"turn_close":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,closedAt:Date.now(),totalMs:r.totalMs||0,totalTokens:r.totalTokens||0,loopCount:r.loopCount||i.loopCount||0}};break}case"memory_used":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryLoaded:Array.isArray(r.loaded)?r.loaded:[],memoryLoadedMeta:r.meta||null}};break}case"dream_memory_loaded":{let i=Array.isArray(r.resident)?r.resident:[];if(r.turnId){let a=this.yeaftDebugTurnsById[r.turnId];a&&(this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...a,dreamMemoryLoaded:i,dreamMemoryLoadedInto:r.loadedInto||"system_prompt.memory"}})}let o={};for(let a of i){let l=a&&typeof a.scope=="string"?a.scope:null,c=l&&/^sessions\/[^/]+$/.test(l)?l:l&&/^group\/[^/]+$/.test(l)?`sessions/${l.slice(6)}`:null;c&&(o[c]={scope:c,sourceScope:l,sessionId:c.slice(9),turnId:r.turnId||null,vpId:r.vpId||null,loadedInto:r.loadedInto||"system_prompt.memory",summary:a.summary||"",truncated:!!a.truncated,receivedAt:Date.now()})}Object.keys(o).length>0&&(this.yeaftDreamPromptLoads={...this.yeaftDreamPromptLoads,...o});break}case"memory_adjust":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,memoryAdjust:{sessionKey:r.sessionKey||null,added:r.added||0,evicted:r.evicted||0,skipped:r.skipped||0,reason:r.reason||""}}};break}case"tool_exec":{if(!r.turnId)break;let i=this.yeaftDebugTurnsById[r.turnId];if(!i)break;let o=[...i.tools||[],{loopNumber:r.loopNumber||0,callId:r.callId||null,name:r.name||"?",durationMs:r.durationMs||0,isError:!!r.isError,toolOutput:r.toolOutput==null?null:String(r.toolOutput)}];this.yeaftDebugTurnsById={...this.yeaftDebugTurnsById,[r.turnId]:{...i,tools:o}};break}case"loop":{if(this.yeaftDebugLoops.push({turnId:r.turnId||null,loopNumber:r.loopNumber||0,model:r.model,systemPrompt:r.systemPrompt,messages:r.messages,response:r.response,toolCalls:r.toolCalls,usage:r.usage||{inputTokens:0,outputTokens:0,totalTokens:0},latencyMs:r.latencyMs,ttfbMs:r.ttfbMs,stopReason:r.stopReason,at:typeof r.at=="number"?r.at:null,rawRequest:r.rawRequest||null,rawResponse:r.rawResponse||null,sessionId:e.sessionId||null,vpId:e.vpId||r.vpId||null}),this.yeaftDebugLoops.length>ru){let i=Pd({loops:this.yeaftDebugLoops,turnsById:this.yeaftDebugTurnsById,turnOrder:this.yeaftDebugTurnOrder,maxLoops:Math.max(ru,this.yeaftDebugHistoryLimit||0)});this.yeaftDebugLoops=i.loops,this.yeaftDebugTurnsById=i.turnsById,this.yeaftDebugTurnOrder=i.turnOrder}break}case"llm_retry":{if(!e.turnId)break;let i=Bs(this,e.agentId||null,e.turnId),o=this.activeVpTurns?.[i];if(!o)break;let a=r.reason==="stream_idle_timeout"?"stream_idle_timeout":"transient_error";this.activeVpTurns={...this.activeVpTurns,[i]:{...o,retryAttempt:r.attempt||0,retryMax:r.maxRetries||0,retryDelayMs:r.delayMs||0,retryReason:a,retryRecoveryMode:r.recoveryMode||"restart"}};break}case"recall":case"consolidate":case"fallback":case"thinking_delta":break;case"reflection":{let i=Wt(this,e.agentId||null,e.conversationId)||"unknown",o=Array.isArray(r.loopRange)?r.loopRange:[0,0],a=`${i}:${r.trigger}:${o[0]}-${o[1]}`,l=this.yeaftReflectionCards[a],c=this.messagesMap[i]||[],d=l?l.anchorMsgId:c.length>0&&c[c.length-1].id||null,u=l?l.anchorOrder:c.length;this.yeaftReflectionCards={...this.yeaftReflectionCards,[a]:{key:a,conversationId:i,turnId:r.turnId||l&&l.turnId||null,loopNumber:r.loopNumber||l&&l.loopNumber||null,trigger:r.trigger,status:r.status,loopRange:o,toolCount:r.toolCount||0,content:r.content||"",durationMs:r.durationMs||0,error:r.error||null,sessionId:e.sessionId||null,anchorMsgId:d,anchorOrder:u,updatedAt:Date.now()}};break}case"model_switched":this.yeaftModel=r.model,this.yeaftModelEffort=r.modelEffort||null;break;case"yeaft_task_event":{let i=r.task;if(!i?.id||!i.sessionId)break;let o=e.agentId||Ie(this,i.sessionId),a=Pe(o,i.sessionId),l={...i,agentId:o},c={...this.yeaftActiveTasksBySession},d={...c[a]||{}};i.status==="running"||na.has(i.status)?d[i.id]=l:delete d[i.id];let u=ta(d);if(Object.keys(u).length>0?c[a]=u:delete c[a],this.yeaftActiveTasksBySession=c,i.status!=="running"){let{[ea(o,i.sessionId,i.id)]:f,...p}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=p}break}case"yeaft_task_cancel_result":{let i=r.taskId||r.task?.id||null,o=r.task?.sessionId||r.sessionId||e.sessionId||null,a=e.agentId||Ie(this,o);if(i&&o&&r.success===!1){let{[ea(a,o,i)]:c,...d}=this.yeaftStoppingTasksById||{};this.yeaftStoppingTasksById=d}let l=r.task;if(l?.id&&l.sessionId){let c=Pe(a,l.sessionId),d={...this.yeaftActiveTasksBySession},u={...d[c]||{}};u[l.id]={...l,agentId:a};let f=ta(u);Object.keys(f).length>0?d[c]=f:delete d[c],this.yeaftActiveTasksBySession=d}break}case"sub_agent_event":{let i=Wt(this,e.agentId||null,e.conversationId)||"unknown",o=r.agentId;if(!o)break;let a=r.payload||{},l=`${i}:${o}`,c=this.yeaftSubAgentCards[l],d=this.messagesMap[i]||[],u=c?c.anchorMsgId:d.length>0&&d[d.length-1].id||null,f=c?c.anchorOrder:d.length,p=c?{...c}:{key:l,conversationId:i,agentId:o,agentName:a.agentName||"sub-agent",status:"running",text:"",toolCallCount:0,turns:0,error:null,expanded:!1,anchorMsgId:u,anchorOrder:f,updatedAt:Date.now(),sessionId:e.sessionId||null};switch(a.agentName&&!p.agentName&&(p.agentName=a.agentName),a.type){case"sub_agent_status":p.status=a.status||p.status,a.error&&(p.error=a.error);break;case"text_delta":break;case"tool_use":case"tool_call":p.toolCallCount=Number(p.toolCallCount||0)+1;break;case"tool_start":break;case"tool_result":case"tool_end":break;case"sub_agent_turn_end":{p.turns+=1;let g=typeof a.content=="string"?a.content.trim():"";g&&(p.text=p.text?`${p.text}
|
|
9
9
|
|
|
10
|
-
${g}`:g),p.status!=="failed"&&p.status!=="closed"&&(p.status=a.status||"idle");break}case"error":a.error&&(p.error=a.error.message||String(a.error));break;default:break}p.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[l]:p};break}case"history_loaded":{let i={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(i.requestId&&!this.isCurrentYeaftHistoryResponse(i))break;let o=e.agentId||null,a=r.sessionId??null,l=Pe(o,a),c=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[l];c&&Xe(this,{traceId:c,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let d=r.mode==="delta"?"delta":"recent",u=this.yeaftSessionHistoryState[l]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(u.latestSeq)?u.latestSeq:null,p=d==="delta"?{...u,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(u.count||0)+(r.count||0)}:{loaded:!0,loading:!1,hasMore:!!r.hasMore,oldestSeq:typeof r.oldestSeq=="number"?r.oldestSeq:null,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},g=i.requestId?this.finishYeaftHistoryLoad(i,p,"completion"):null;g||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[l]:p});let b=Pe(o?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(l===b)d==="recent"&&(this.yeaftHasMoreHistory=p.hasMore,this.yeaftOldestLoadedSeq=p.oldestSeq),this.yeaftLoadingMoreHistory=!!g?.loading;else if(this.yeaftLoadingMoreHistory){let h=this.yeaftSessionHistoryState[b]||null;this.yeaftLoadingMoreHistory=!!h?.loading}}break;case"vp_snapshot":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vp&&i.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vpId&&i.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let i=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);i&&(this._vpCrudPending.delete(r.requestId),i.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=r.sessions||[];if(Array.isArray(r.projects)&&e.agentId&&(this.sessionProjects=[...this.sessionProjects.filter(u=>u.agentId!==e.agentId),...r.projects.map(u=>({...u,agentId:e.agentId}))]),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let u=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...u,{agentId:e.agentId||null,sessions:o}];break}let a=i&&i.activeSessionId||null,l=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;i&&(i.applySnapshot(o,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let c=i&&i.activeSessionId||null,d=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&c){let u=d||Ie(this,c,e.agentId||null),f=Pe(u,c),p=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(c,{agentId:u,force:l!==u||oc(c,a,p)})}break}case"group_roster_changed":case"session_roster_changed":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyCrudResult(r,e.agentId||null);let o=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(o){this._sessionCrudPending.delete(r.requestId);let a=r.session||r.group||null,l=a&&e.agentId&&!a.agentId?{...a,agentId:e.agentId}:a,c=r.sessionId||null,d=r.sessions||null;o.resolve({ok:!!r.ok,op:r.op,session:l,sessionId:c,sessions:d,config:r.config||null,error:r.error||null})}break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let i=Oo(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[i]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let o=dt(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...o?{[o]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let i=Bs(this,e.agentId||null,r.turnId),o=r.sessionId||this.activeVpTurns?.[i]?.sessionId||null;r.reason==="end_turn"&&o&&this.markYeaftSessionUnread(o,e.agentId||null);let{[i]:a,...l}=this.activeVpTurns;this.activeVpTurns=l;let{[i]:c,...d}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=d,this.clearYeaftSessionProcessingIfIdle(r.sessionId||a?.sessionId||null,{agentId:e.agentId||a?.agentId||null});let f={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",p=Date.now(),g=Wt(this,e.agentId||null,e.conversationId);if(g&&Array.isArray(this.messagesMap[g])){let b=this.messagesMap[g],h=Wd(b,r);for(let A=0;A<b.length;A++){let w=b[A];if(!w||w.type!=="assistant")continue;let S=w.sessionId??w.groupId;r.sessionId&&S&&S!==r.sessionId||r.vpId&&w.speakerVpId&&w.speakerVpId!==r.vpId||r.turnId&&w.turnId&&w.turnId!==r.turnId||w.status&&w.status!=="pending"||(w.status=f,w.turnEndAt=p,w.turnEndReason=r.reason||null,r.detail&&(w.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(w.turnDurationMs=r.durationMs),h=!0)}h&&(this.messagesMap={...this.messagesMap,[g]:b.slice()})}break}case"yeaft_turn_aborted":{let i=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&i.push(r.turnId);let o=r.sessionId||null,a=r.vpId||null,l=new Set;for(let f of i){let p=Bs(this,e.agentId||null,f),g=this.activeVpTurns?.[p]||null;(!g||pt(g,g.sessionId,e.agentId||null))&&l.add(p)}if(a)for(let[f,p]of Object.entries(this.activeVpTurns||{}))!p||p.vpId!==a||pt(p,o,e.agentId||null)&&l.add(f);if(l.size===0)break;let c=o,d={...this.activeVpTurns||{}},u={...this.stoppingVpTurnIds||{}};for(let f of l){let p=d[f];!c&&p?.sessionId&&(c=p.sessionId),delete d[f],delete u[f]}this.activeVpTurns=d,this.stoppingVpTurnIds=u,this.clearYeaftSessionProcessingIfIdle(c||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let i=r.sessionId||e.sessionId||null;i?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([o])=>this.activeVpTurns?.[o])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(i,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Gd(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let i=Wt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Ad(this.yeaftVpTyping,i,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let i=Wt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=xd(this.yeaftVpTyping,i,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;let i=r.sessionId||null,o=e.agentId||null,a=Fr(o,i,r.vpId),l={agentId:o,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:i,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[a]:l},i&&Nr.has(r.state)){let c=dt(o,i);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...c?{[c]:!0}:{[i]:!0}}}else i&&this.clearYeaftSessionProcessingIfIdle(i,{agentId:o});this.restoreActiveYeaftSessionFromStatuses([l],o);break}case"vp_status_snapshot":{let i=Array.isArray(r.statuses)?r.statuses:[],o=r.sessionId;if(o==null){let a={...this.vpStatuses||{}};if(e.agentId)for(let[l,c]of Object.entries(a))(!c?.agentId||c.agentId===e.agentId)&&delete a[l];else for(let l of Object.keys(a))delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Fr(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}else{let a={...this.vpStatuses};for(let[l,c]of Object.entries(a))c&&c.sessionId===o&&(!e.agentId||!c.agentId||c.agentId===e.agentId)&&delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Fr(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}this.yeaftProcessingSessions=Th(this,e.agentId||null,i,o??null),this.restoreActiveYeaftSessionFromStatuses(i,e.agentId||null);break}case"yeaft_dream_snapshot":{let i=r&&r.snapshot,o=i&&typeof i.scope=="string"?i.scope:null;o&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[o]:{...i,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamStatus(r);break}case"yeaft_dream_result":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let o=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!o)break;let a=this.yeaftDreamLatest[o]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:{scope:o,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:a?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:a?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:a?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:a?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:a?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:a?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:a?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:a?.totalTokens??0,metrics:r.metrics||a?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||a?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(o,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let i=r?.phase||"unknown",o=null;typeof r?.target=="string"&&r.target.includes("/")?o=r.target:typeof r?.sessionId=="string"&&r.sessionId?o=`sessions/${r.sessionId}`:o="*";let a=i==="done",l=i==="error"||r?.status==="error",c=!a&&!l,d=u=>{let f=this.yeaftDreamLatest[u]||null;return{scope:u,phase:i,status:l?"error":a?"success":"running",startedAt:f?.startedAt&&c?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:a||l?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:l?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:f?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:f?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:f?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:f?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:f?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:f?.totalTokens??0,metrics:r?.metrics||f?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||f?.passBreakdown||null,isRunning:c}};if(o==="*"){let u={...this.yeaftDreamLatest,"*":d("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(u[f]=d(f));this.yeaftDreamLatest=u}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:d(o)};this._appendDreamEvent(o,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>ou&&a.splice(0,a.length-ou),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),c({ok:!1,op:e,error:{code:"timeout",message:"group_crud timeout"}}))},1e4);this._sessionCrudPending.set(n,{resolve:u=>{clearTimeout(d),c(u)}}),this.sendWsMessage(o)})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=Ie(this,e,t);if(!s)return!1;let n=yr(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Ie(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Ie(this,e,t);if(!s)return!1;let n=yr(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||au(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?Ie(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let c=this.agents.find(d=>d.id===r);this.activateYeaftAgent(r,c||null)}else r&&n&&this.activateYeaftAgent(r);if(r&&n&&this.markYeaftSessionRead(n,r),!o&&n===s)return;let a=Pe(r,n),l=this.yeaftSessionHistoryState[a]||null;if(this.pruneYeaftMessageWindow(n),r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let c=this.yeaftConversationIdsByAgent?.[r]||null;c||(c=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:c}),this.yeaftConversationId=c,this.messagesMap[c]||(this.messagesMap[c]=[]),this.currentView==="yeaft"&&(this.activeConversations=[c])}try{let c=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();c&&typeof c.setActive=="function"&&c.setActive(n,r||null);let d=c?.activeSessionKey||null;d?localStorage.setItem("lastViewedYeaftSession",d):localStorage.removeItem("lastViewedYeaftSession")}catch{}if(this.syncActiveYeaftHistoryLoad(),!l?.loading&&r&&n){let c=Number.isFinite(l?.latestSeq)?l.latestSeq:null,d={type:"yeaft_load_history",agentId:r,sessionId:n},u=!!l?.loaded,f=bo({sessionState:l,hasCachedSessionRows:!1,force:o});if(!f&&c!==null?d.afterSeq=c:d.limit=Or,!f&&u&&c===null){this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...l||{hasMore:!1,oldestSeq:null,count:0},loaded:!0,loading:!1,syncingAfterSeq:null}},this.syncActiveYeaftHistoryLoad();return}let p=null;if(!f&&u){if(l?.syncingAfterSeq===c)return;p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:c}),this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...this.yeaftSessionHistoryState[a],syncingAfterSeq:c}}}else p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1,latestSeq:f?null:c});p&&(d.requestId=p.requestId),this.sendWsMessage(d)}},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:Ie(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()?iu:sa,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(Ae(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null){let s=new Set;if(this.sessionCatalog=(Array.isArray(e)?e:[]).filter(n=>!n?.catalogKey||s.has(n.catalogKey)?!1:(s.add(n.catalogKey),!0)).map(n=>({...n})),Array.isArray(t)){this.sessionProjects=t.filter(r=>r?.id&&r?.agentId);let n=new Map;for(let r of this.sessionProjects)for(let i of r.sessionIds||[])n.set(`${r.agentId}${i}`,r.id);this.sessionCatalog=this.sessionCatalog.map(r=>r.runtimeProvider==="yeaft"?{...r,projectId:n.get(`${r.routeRef?.agentId}${r.routeRef?.sessionId}`)||null}:r)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent;if(!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});if(!this.agents.find(o=>o.id===n)?.online)return Promise.resolve({ok:!1,error:{code:"agent_offline"}});let i=`project_${crypto.randomUUID()}`;return new Promise(o=>{let a=setTimeout(()=>{delete this.projectMutationRequests[i],o({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[i]={resolve:c=>{clearTimeout(a),o(c)}},this.sendWsMessage({type:"yeaft_project_mutation",agentId:n,requestId:i,op:e,...t})||(clearTimeout(a),delete this.projectMutationRequests[i],o({ok:!1,error:{code:"send_failed"}}))})},finishProjectMutation(e,t=null){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;if(s&&delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t){this.sessionProjects=[...this.sessionProjects.filter(r=>r.agentId!==t),...e.projects.map(r=>({...r,agentId:t}))];let n=new Map;for(let r of e.projects)for(let i of r.sessionIds||[])n.set(i,r.id);this.sessionCatalog=this.sessionCatalog.map(r=>r.runtimeProvider==="yeaft"&&r.routeRef?.agentId===t?{...r,projectId:n.get(r.routeRef.sessionId)||null}:r)}return s?.resolve(e),!!s},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=lo(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=lo(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){return Tl(this,e)},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;return this.activeCatalogKey=e.catalogKey,t==="yeaft"?(this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!0}),!0):t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s),!0)},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Rs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?a:(Pl(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return Ml(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Rs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Kl(this,e)},parseWsMessage(e){return Yl(this,e)},connect(){Gl(this)},ensureConnected(){return bn(this)},scheduleReconnect(){Ql(this)},manualReconnect(){Xl(this)},startHeartbeat(){Zl(this)},stopHeartbeat(){Jl(this)},setupVisibilityHandler(){ec(this)},handleMessage(e){zc(this,e)},getOrCreateExecutionStatus(e){return Lo(this,e)},handleAssistantOutputFrame(e,t){$c(this,e,t)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t)},addMessageToConversation(e,t){wr(this,e,t)},appendToAssistantMessageForConversation(e,t,s){lc(this,e,t,s)},finishStreamingForConversation(e,t){cc(this,e,t)},sweepStaleStreamingForConversation(e){dc(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){uc(this,e)},formatDbMessage(e){return wo(e)},formatDbMessageForHistoryHydration(e){return fc(e)},selectAgent(e){return ed(this,e)},createConversation(e,t=null,s=null,n=void 0){td(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){sd(this,e,t,s,n,r)},selectConversation(e,t){nd(this,e,t)},updateConversationSettings(e,t){qo(this,e,t)},toggleConversationMcp(e,t){rd(this,e,t)},deleteConversation(e,t){od(this,e,t)},closeSession(e,t){id(this,e,t)},appendColumn(e){dd(this,e)},removeColumn(e){ud(this,e)},sendMessageToConversation(e,t,s=[],n={}){pd(this,e,t,s,n)},cancelExecutionForConversation(e){fd(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t){let s=this.panels.find(n=>n.id===e);s&&(s.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]&&(this.messagesMap[t]=[],this.requestChatHistory(t,{mode:"recent",turns:5})),this.saveOpenSessions())},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!us()?.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=Ie(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?us()?.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||Ie(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>pt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>pt(l,e,n)&&Nr.has(l?.state)))return;let i=dt(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],qr(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){ad(this,e,t,s)},cancelExecution(){ld(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],Gd(this,this.currentAgent)},cancelYeaftSession(e){let t=Ie(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!pt(s,e,t))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([s])=>this.activeVpTurns?.[s])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,s])=>!pt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Ie(this,t);if(!n||!e)return;let r=Bs(this,n,e);this.stoppingVpTurnIds={...this.stoppingVpTurnIds,[r]:Date.now()};let i={type:"yeaft_abort_turn",agentId:n,turnId:e};t&&(i.sessionId=t),s&&(i.vpId=s),this.sendWsMessage(i)},cancelVpTurnForSession(e,t=null){if(!e)return!1;let s=t||this.yeaftActiveSessionFilter||null;if(!s)return!1;let n=Ie(this,s);if(!n)return!1;let r=this.activeVpTurns||{},i=null,o=-1/0;for(let[a,l]of Object.entries(r)){if(!l||l.vpId!==e||!pt(l,s,n))continue;let c=typeof l.startedAt=="number"?l.startedAt:0;c>=o&&(o=c,i=a)}if(!i){let a=this.vpStatuses?.[Fr(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){cd(this,e,t,s)},refreshAgents(){gd(this)},refreshConversation(){md(this)},restartAgent(e){hd(this,e)},upgradeAgent(e){vd(this,e)},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=ds(this),t=Ie(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!r)return!1;let i=An();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:i};let o={type:"yeaft_load_history",agentId:t,limit:Or,sessionId:e,requestId:r.requestId,perfTraceId:i};return Xe(this,{traceId:i,phase:"history.request_send",agentId:t,sessionId:e,messageType:o.type,bytes:JSON.stringify(o).length,detail:{mode:"manual-reload",limit:Or}}),this.sendWsMessage(o),!0},loadMoreYeaftHistory(e=Ln()){if(this.currentView!=="yeaft"||this.yeaftLoadingMoreHistory||!this.yeaftHasMoreHistory||this.yeaftOldestLoadedSeq==null)return;let t=ds(this),s=Ie(this,t);if(!s)return;let n=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Ln())),r=Pe(s,t),i=this.beginYeaftHistoryLoad({agentId:s,sessionId:t,mode:"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[r]?.latestSeq??null});if(!i)return;let o=An();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[r]:o};let a={type:"yeaft_load_more_history",agentId:s,sessionId:t,requestId:i.requestId,beforeSeq:this.yeaftOldestLoadedSeq,turns:n,perfTraceId:o};Xe(this,{traceId:o,phase:"history_more.request_send",agentId:s,sessionId:t,messageType:a.type,bytes:JSON.stringify(a).length,detail:{beforeSeq:a.beforeSeq,turns:a.turns}}),this.sendWsMessage(a)},checkPendingRecovery(){Rl(this)},performRecovery(){_l(this)},dismissRecovery(){El(this)},autoRestoreConversation(e){Dl(this,e)},saveOpenSessions(){Es(this)},getLastSession(){return $l(this)},clearLastSession(){Vl(this)},listHistorySessions(e){Fl(this,e)},listFolders(){return Ol(this)},listFoldersForAgent(e,t){return Hl(this,e,t)},listModelsForAgent(e,t){return ql(this,e,t)},listHistorySessionsForAgent(e,t,s){Nl(this,e,t,s)},async loadGlobalSessions(e=20){return Bl(this,e)},async deleteGlobalSession(e){return Wl(this,e)},findAgentForSession(e){return uo(this,e)},isSessionResumable(e){return Ul(this,e)},_isRecentlyClosed(e){return ns(this,e)},_startProcessingWatchdog(e){Ls(this,e)},_resetProcessingWatchdog(e){kr(this,e)},_stopProcessingWatchdog(e){Ae(this,e)},startRefreshTimeout(e){let t=e||this.currentConversation;t&&(this._refreshTimeouts||(this._refreshTimeouts={}),this._refreshTimeouts[t]&&clearTimeout(this._refreshTimeouts[t]),this._refreshTimeouts[t]=setTimeout(()=>{this.setRefreshingSession(t,!1),delete this._refreshTimeouts[t]},1e4))},toggleTheme(){this.theme=this.theme==="dark"?"light":"dark",this.themeFollowSystem=!1,localStorage.setItem("theme",this.theme),document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light")},initTheme(){if(document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"),this.themeFollowSystem&&typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=s=>{this.themeFollowSystem&&(this.theme=s.matches?"dark":"light",document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"))};e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t)}},loadModelsDevRegistry({forceRefresh:e=!1}={}){let t=this.modelsDevRegistry.loaded&&!this.modelsDevRegistry.error&&Date.now()-this.modelsDevRegistry.fetchedAt<36e5;if(!e&&t)return Promise.resolve(this.modelsDevRegistry);let s=this.currentAgent;if(!s)return Promise.resolve(this.modelsDevRegistry);if(this._modelsDevPending&&(!e||this._modelsDevPending.force))return new Promise(n=>this._modelsDevPending.resolvers.push(n));if(this._modelsDevPending){let n=this._modelsDevPending;this._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(this.modelsDevRegistry)}return new Promise(n=>{let r={resolvers:[n],force:e,timer:null};this._modelsDevPending=r;try{this.sendWsMessage({type:"get_models_dev_registry",agentId:s,forceRefresh:e})}catch{this._modelsDevPending===r&&(this._modelsDevPending=null),n(this.modelsDevRegistry);return}r.timer=setTimeout(()=>{if(this._modelsDevPending===r){this._modelsDevPending=null;for(let i of r.resolvers)i(this.modelsDevRegistry)}},2e4)})},changeLocale(e){if(this.locale=e,hn(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=_e();try{let t={};e.token&&(t.Authorization=`Bearer ${e.token}`);let s=await fetch("/api/expert-roles/custom",{headers:t});if(s.ok){let n=await s.json();this.customExpertRoles=n.roles||[]}}catch{}},async createCustomExpertRole(e){let t=_e();try{let s={"Content-Type":"application/json"};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch("/api/expert-roles/custom",{method:"POST",headers:s,body:JSON.stringify(e)});if(n.ok){let r=await n.json();return this.customExpertRoles.push(r.role),r.role}else{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to create custom expert role")}}catch(s){throw s}},async updateCustomExpertRole(e,t){let s=_e();try{let n={"Content-Type":"application/json"};s.token&&(n.Authorization=`Bearer ${s.token}`);let r=await fetch(`/api/expert-roles/custom/${e}`,{method:"PUT",headers:n,body:JSON.stringify(t)});if(r.ok){let i=await r.json(),o=this.customExpertRoles.findIndex(a=>a.id===e);return o!==-1&&(this.customExpertRoles[o]=i.role),i.role}else{let i=await r.json().catch(()=>({}));throw new Error(i.error||"Failed to update custom expert role")}}catch(n){throw n}},async deleteCustomExpertRole(e){let t=_e();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},toggleWorkbench(){this.workbenchExpanded=!this.workbenchExpanded,this.workbenchExpanded||(this.workbenchMaximized=!1)},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},openFileInExplorer(e){this.currentConversation&&(this.workbenchExpanded=!0,window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:e,conversationId:this.currentConversation}})))},logout(){_e().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function ia(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Wh(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 aa(e){if(!e)return Ut[0];let t=String(e).toLowerCase();return Bh[t]||Ut[Wh(t)%Ut.length]}function Uh(e){return aa(e).background}function jh(e){return aa(e).foreground}function oa(){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 zh(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 Nh,Ut,Bh,Mw,yt,Ws=F(()=>{({defineStore:Nh}=Pinia);Ut=[{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)"}],Bh=Object.freeze({steve:Ut[8],ada:Ut[3],linus:Ut[0],martin:Ut[4]}),Mw=Ut.map(e=>e.background);yt=Nh("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?oa().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>zh(e.vps[t],oa()),vpInitial:e=>t=>{let s=e.vps[t],n=oa().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:Uh(t)},vpTextColor:()=>e=>jh(e),vpAvatarMotif:()=>e=>aa(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(ia(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){ia(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&&ia(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 la(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 Wr(e){return!e||typeof e!="object"?0:la(e.lastMessageAt)||la(e.updatedAt)||la(e.createdAt)||0}function ca(e,t){let s=Wr(t)-Wr(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function du(e){return[...Array.isArray(e)?e:[]].sort(ca)}var Ur=F(()=>{});function uu(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(mu)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Kh(e){try{typeof localStorage<"u"&&localStorage.setItem(mu,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function pu(){try{return typeof localStorage>"u"?[]:Vn(JSON.parse(localStorage.getItem(hu)||"[]"))}catch{return[]}}function Yh(e){try{typeof localStorage<"u"&&localStorage.setItem(hu,JSON.stringify(Vn(e)))}catch{}}function vu(e,t){return`${e||""}${t||""}`}function Pt(e){return e&&e.agentId&&e.id?vu(e.agentId,e.id):""}function bt(e,t){return t?e?vu(e,t):String(t):""}function Gh(e){return typeof e=="string"?e:String(e||"")}function st(e,t,s=null){let n=Gh(t);if(!n)return"";let r=bt(s,n),i=r?e.sessions[r]:null;if(i&&(s||i.agentId||e.inventoryIdentityMode==="legacy-bare"))return r;if(s){let c=e.sessions[n];return e.inventoryIdentityMode==="legacy-bare"&&c&&!c.agentId?n:""}let o=e.sessions[n];if(o){if(o.agentId||e.inventoryIdentityMode==="legacy-bare")return n;let c=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return c?.agentId&&c.id===n?e.activeSessionKey:""}if(e.activeSessionKey&&e.sessions[e.activeSessionKey]?.id===n)return e.activeSessionKey;let a=e.sessionOrder.filter(c=>e.sessions[c]?.id===n),l=Fn();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function da(e,t,s=null){return st(e,t,s)||""}function ua(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 Qh(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=Fn(),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=Pn(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function jr(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=Fn();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")||"";Pn(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function Vn(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 pa(e,t){let s=Vn(e),n=new Set(s),r=Vn(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function zr(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 fu(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function gu(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 Fn(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var mu,hu,Xh,yu,bu=F(()=>{Ur();Rn();mu="yeaft-session-order-by-agent",hu="yeaft-session-order-global";({defineStore:Xh}=Pinia);yu=Xh("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=Fn(),n=s&&Array.isArray(s.pinnedSessions)?new Set(s.pinnedSessions):new Set;for(let d of t)d&&d.id&&d.pinned&&n.add(d.id);let r=[],i=[];for(let d of t)d.pinned||!d.agentId&&n.has(d.id)?r.push(d):i.push(d);let o=d=>[...d].sort((u,f)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(f?.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER;return p!==g?p-g:ca(u,f)}),a=[...o(r),...o(i)],l=pu();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let f=c.has(Pt(d))?c.get(Pt(d)):Number.MAX_SAFE_INTEGER,p=c.has(Pt(u))?c.get(Pt(u)):Number.MAX_SAFE_INTEGER;return f!==p?f-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=st(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){ua(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);a.add(g),o[g]=this._normalize(p,t,zr(this.sessions[g]))}for(let p of this.sessionOrder){let g=this.sessions[p];g&&g.agentId===t&&!a.has(p)&&delete o[p]}let l=this.sessionOrder.filter(p=>o[p]),c=new Set(l),d=[];for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],f=pu();if(f.length>0){let p=new Map(u.map(A=>[Pt(o[A]),A]).filter(([A])=>A)),g=f.map(A=>p.get(A)).filter(Boolean),b=new Set(g);u=[...g,...u.filter(A=>!b.has(A))];let h=new Map(f.map((A,w)=>[A,w]));for(let A of u){let w=Pt(o[A]);w&&h.has(w)&&(o[A]={...o[A],sortOrder:h.get(w)})}}if(t&&f.length===0){let p=uu(),g=Vn(p[t]);if(g.length>0){let b=g.map(m=>bt(t,m)),h=new Set(b),A=pa(u.filter(m=>o[m]?.agentId===t),b),w=this.sessionOrder.some(m=>o[m]?.agentId===t),S=0;w?u=this.sessionOrder.filter(m=>o[m]).map(m=>o[m]?.agentId===t?A[S++]:m).concat(A.slice(S)):u=u.map(m=>o[m]?.agentId===t?A[S++]:m);let y=new Map(b.map((m,v)=>[m,v]));for(let m of A)o[m]&&h.has(m)&&(o[m]={...o[m],sortOrder:y.get(m)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=bt(null,c.id);a[d]=this._normalize(c,null,zr(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=Qh(this)||jr(this)),this.lastSnapshotAt=Date.now();let i=Fn();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?st(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(S=>this.sessions[S]&&(!t||this.sessions[S].agentId===t)&&this.sessions[S].running).sort((S,y)=>gu(this.sessions[y])-gu(this.sessions[S]))[0]||null,f=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,g=p?.id||null,b=g?st(this,g,p?.raw?.agentId||null):"",h=f||(d?c.id:null)||g,A=u||(d?l:"")||b||da(this,h,t),w=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!st(this,this.activeSessionId,w)?(this.activeSessionId=h,this.activeSessionKey=A||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=h,this.activeSessionKey=A||null):this.activeSessionId&&(this.activeSessionKey=da(this,this.activeSessionId,w)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let S=this.activeSessionId||h,y=null;if((i.yeaftActiveSessionFilter&&!st(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&S)&&(y=S),y){let m=da(this,y),v=m&&this.sessions[m]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(y,{agentId:v,force:!0}):i.yeaftActiveSessionFilter=y,this.activeSessionKey=m||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=bt(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=st(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)ua(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=st(this,s,n)||bt(n,s),i=this.sessions[r];if(!i){let o=this._normalize({id:s,name:e.name||s,roster:Array.isArray(e.roster)?e.roster:[],defaultVpId:e.defaultVpId||null},n);this.sessions[r]=o,this.sessionOrder.push(r),jr(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},jr(this)},applyCrudResult(e,t=null){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let s=e.session||e.group||null,n=t||e.agentId||s?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,n),e.ok&&(e.op==="create"||e.op==="restore")&&s&&s.id&&this.applySnapshotUpsert(s,n)&&this.setActive(s.id,n);let r=e.sessionId||e.groupId,i=this.inventoryIdentityMode==="legacy-bare",o=r&&(n||i)?st(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)ua(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=st(this,e.id,s)||bt(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,zr(i))},r||this.sessionOrder.push(n),jr(this),n},setActive(e,t=null){let s=st(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=pa(s,t.map(l=>bt(e,l)));if(n.length===0)return[];let r=new Map(n.map((l,c)=>[l,c])),i=0;this.sessionOrder=this.sessionOrder.map(l=>this.sessions[l]?.agentId===e?n[i++]:l);for(let l of n)this.sessions[l]={...this.sessions[l],sortOrder:r.get(l)};let o=uu(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Kh(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Pt(this.sessions[a])).filter(Boolean),s=pa(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Pt(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=Pt(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Yh(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=st(this,e,s);!e||!n||!this.sessions[n]||(this.sessions[n]={...this.sessions[n],pinned:!!t})},markPending(e,t){e&&(this.pending[e]=t)},clearLastResult(){this.lastCrudResult=null},resetInventory(){this.sessions={},this.sessionOrder=[],this.activeSessionId=null,this.activeSessionKey=null,this.inventoryIdentityMode="empty",this._retiredBareActiveSessionId=null,this._preferredExactSessionIdentity=null,this.lastSnapshotAt=0},beginInventoryCommit(e=null,t=null){if(this.resetInventory(),e&&t){let s=bt(t,e);this.activeSessionId=e,this.activeSessionKey=s,this._preferredExactSessionIdentity={sessionId:e,agentId:t,key:s}}else e&&(this._retiredBareActiveSessionId=e)},_normalize(e,t=null,s=!1){return{id:e.id,name:e.name||e.id,roster:Array.isArray(e.roster)?e.roster.slice():[],defaultVpId:e.defaultVpId||null,announcement:typeof e.announcement=="string"?e.announcement:"",config:e.config&&typeof e.config=="object"?{...e.config}:{},workDir:typeof e.workDir=="string"?e.workDir:"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,lastMessageAt:e.lastMessageAt||null,running:fu(e),active:fu(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:zr(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function Kr(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function fa(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Su(){let e=Kr();if(e)try{return e.getActiveToken?.()||e.token||fa()}catch{return e.token||fa()}return fa()}function Jh(e,t){if(!e)return!1;let s=Su();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=Kr();return n&&(n.token=e),!0}function ev(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 ku(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function tv(e){if(!e)return!1;let t=e.pathname;return!!(Zh.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function sv(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function nv(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function rv(e,t){return{...e||{},headers:t}}function iv(e,t,s,n){let r=Kr();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function Iu(){if(wu||typeof window>"u"||!window.fetch)return;wu=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=ev(s),i=ku(r)&&!tv(r),o=ku(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?Kr():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let f=sv(s,n);a=nv(f),a||(a=Su(),a&&(f.set("Authorization",`Bearer ${a}`),o=rv(o,f)))}let u=await e(s,o);try{let f=u.headers&&u.headers.get&&u.headers.get("X-New-Token");f&&Jh(f,a),i&&u.status===401&&iv(u,a,c,d)}catch{}return u}}var wu,Zh,Cu=F(()=>{wu=!1,Zh=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 Au,xu=F(()=>{Au={"common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","chat.toolActionsOmitted":"\u5DF2\u7701\u7565 {count} \u4E2A\u5386\u53F2\u5DE5\u5177\u52A8\u4F5C","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
|
|
10
|
+
${g}`:g),p.status!=="failed"&&p.status!=="closed"&&(p.status=a.status||"idle");break}case"error":a.error&&(p.error=a.error.message||String(a.error));break;default:break}p.updatedAt=Date.now(),this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[l]:p};break}case"history_loaded":{let i={...r,agentId:e.agentId||null,requestId:r.requestId||e.requestId||null};if(i.requestId&&!this.isCurrentYeaftHistoryResponse(i))break;let o=e.agentId||null,a=r.sessionId??null,l=Pe(o,a),c=e.perfTraceId||this.yeaftHistoryPerfTraceBySession?.[l];c&&Xe(this,{traceId:c,phase:"history.loaded_event",agentId:e.agentId||null,sessionId:r.sessionId||null,messageType:r.type,detail:{mode:r.mode||"recent",count:r.count||0,hasMore:!!r.hasMore}});let d=r.mode==="delta"?"delta":"recent",u=this.yeaftSessionHistoryState[l]||{},f=Number.isFinite(r.latestSeq)?r.latestSeq:Number.isFinite(u.latestSeq)?u.latestSeq:null,p=d==="delta"?{...u,loaded:!0,loading:!1,latestSeq:f,syncingAfterSeq:null,count:(u.count||0)+(r.count||0)}:{loaded:!0,loading:!1,hasMore:!!r.hasMore,oldestSeq:typeof r.oldestSeq=="number"?r.oldestSeq:null,count:typeof r.count=="number"?r.count:0,latestSeq:f,syncingAfterSeq:null},g=i.requestId?this.finishYeaftHistoryLoad(i,p,"completion"):null;g||(this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[l]:p});let b=Pe(o?this.currentAgent:null,this.yeaftActiveSessionFilter??null);if(l===b)d==="recent"&&(this.yeaftHasMoreHistory=p.hasMore,this.yeaftOldestLoadedSeq=p.oldestSeq),this.yeaftLoadingMoreHistory=!!g?.loading;else if(this.yeaftLoadingMoreHistory){let h=this.yeaftSessionHistoryState[b]||null;this.yeaftLoadingMoreHistory=!!h?.loading}}break;case"vp_snapshot":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applySnapshot(r,e.agentId||null,e.requestId||null);break}case"vp_snapshot_error":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.failSnapshot(e.agentId||null,e.requestId||null,r.error||r.message||"VP library request failed");break}case"vp_updated":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vp&&i.upsert(r.vp,r.reason,e.agentId||null);break}case"vp_removed":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&r.vpId&&i.remove(r.vpId,r.reason,e.agentId||null);break}case"vp_crud_result":{let i=this._vpCrudPending&&this._vpCrudPending.get(r.requestId);i&&(this._vpCrudPending.delete(r.requestId),i.resolve({ok:!!r.ok,op:r.op,vpId:r.vpId,vp:r.vp,error:r.error||null}));break}case"group_list_updated":case"session_list_updated":case"yeaft_session_hydrate":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore(),o=r.sessions||[];if(r.projectsAuthoritative===!0&&Array.isArray(r.projects)?this.applySessionCatalogSnapshot(this.sessionCatalog,r.projects):Array.isArray(r.projects)&&e.agentId&&this.applyLegacyProjectSnapshot(r.projects,e.agentId),r.type!=="yeaft_session_hydrate"&&this.yeaftSessionHydrateRequestId&&this.yeaftSessionInventoryCompleteSupported===!0){let u=Array.isArray(this.yeaftSessionHydrateSlices)?this.yeaftSessionHydrateSlices.filter(f=>f.agentId!==(e.agentId||null)):[];this.yeaftSessionHydrateSlices=[...u,{agentId:e.agentId||null,sessions:o}];break}let a=i&&i.activeSessionId||null,l=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;i&&(i.applySnapshot(o,e.agentId||null),this._hasHandledYeaftSessionHydrate=!0,this.yeaftSessionHydrateError=null);let c=i&&i.activeSessionId||null,d=i?.activeSessionKey&&i.sessions?.[i.activeSessionKey]?.agentId||null;if(this.currentView==="yeaft"&&c){let u=d||Ie(this,c,e.agentId||null),f=Pe(u,c),p=this.yeaftSessionHistoryState[f]||null;this.setActiveSessionFilter(c,{agentId:u,force:l!==u||oc(c,a,p)})}break}case"group_roster_changed":case"session_roster_changed":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyRosterChange(r,e.agentId||null);break}case"group_crud_result":case"session_crud_result":{let i=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();i&&i.applyCrudResult(r,e.agentId||null);let o=this._sessionCrudPending&&this._sessionCrudPending.get(r.requestId);if(o){this._sessionCrudPending.delete(r.requestId);let a=r.session||r.group||null,l=a&&e.agentId&&!a.agentId?{...a,agentId:e.agentId}:a,c=r.sessionId||null,d=r.sessions||null;o.resolve({ok:!!r.ok,op:r.op,session:l,sessionId:c,sessions:d,config:r.config||null,error:r.error||null})}break}case"vp_turn_start":{if(!r.turnId||!r.vpId)break;let i=Oo(e.agentId||null,r.turnId)||r.turnId;if(this.activeVpTurns={...this.activeVpTurns,[i]:{agentId:e.agentId||null,turnId:r.turnId,vpId:r.vpId,sessionId:r.sessionId||null,threadId:r.threadId||null,isStreaming:!0,startedAt:r.ts||Date.now()}},r.sessionId){let o=dt(e.agentId||null,r.sessionId);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...o?{[o]:!0}:{[r.sessionId]:!0}}}break}case"vp_turn_end":{if(!r.turnId)break;let i=Bs(this,e.agentId||null,r.turnId),o=r.sessionId||this.activeVpTurns?.[i]?.sessionId||null;r.reason==="end_turn"&&o&&this.markYeaftSessionUnread(o,e.agentId||null);let{[i]:a,...l}=this.activeVpTurns;this.activeVpTurns=l;let{[i]:c,...d}=this.stoppingVpTurnIds;this.stoppingVpTurnIds=d,this.clearYeaftSessionProcessingIfIdle(r.sessionId||a?.sessionId||null,{agentId:e.agentId||a?.agentId||null});let f={end_turn:"completed",route_forward:"completed",aborted:"aborted",errored:"errored",error:"errored",cancelled:"cancelled",canceled:"cancelled"}[r.reason]||"completed",p=Date.now(),g=Wt(this,e.agentId||null,e.conversationId);if(g&&Array.isArray(this.messagesMap[g])){let b=this.messagesMap[g],h=Wd(b,r);for(let A=0;A<b.length;A++){let w=b[A];if(!w||w.type!=="assistant")continue;let S=w.sessionId??w.groupId;r.sessionId&&S&&S!==r.sessionId||r.vpId&&w.speakerVpId&&w.speakerVpId!==r.vpId||r.turnId&&w.turnId&&w.turnId!==r.turnId||w.status&&w.status!=="pending"||(w.status=f,w.turnEndAt=p,w.turnEndReason=r.reason||null,r.detail&&(w.turnEndDetail=r.detail),Number.isFinite(r.durationMs)&&(w.turnDurationMs=r.durationMs),h=!0)}h&&(this.messagesMap={...this.messagesMap,[g]:b.slice()})}break}case"yeaft_turn_aborted":{let i=Array.isArray(r.turnIds)?r.turnIds.filter(Boolean):[];r.turnId&&i.push(r.turnId);let o=r.sessionId||null,a=r.vpId||null,l=new Set;for(let f of i){let p=Bs(this,e.agentId||null,f),g=this.activeVpTurns?.[p]||null;(!g||pt(g,g.sessionId,e.agentId||null))&&l.add(p)}if(a)for(let[f,p]of Object.entries(this.activeVpTurns||{}))!p||p.vpId!==a||pt(p,o,e.agentId||null)&&l.add(f);if(l.size===0)break;let c=o,d={...this.activeVpTurns||{}},u={...this.stoppingVpTurnIds||{}};for(let f of l){let p=d[f];!c&&p?.sessionId&&(c=p.sessionId),delete d[f],delete u[f]}this.activeVpTurns=d,this.stoppingVpTurnIds=u,this.clearYeaftSessionProcessingIfIdle(c||null,{agentId:e.agentId||null});break}case"yeaft_aborted":{let i=r.sessionId||e.sessionId||null;i?(this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([o])=>this.activeVpTurns?.[o])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,o])=>!pt(o,i,e.agentId||null))),this.clearYeaftSessionProcessingIfIdle(i,{agentId:e.agentId||null,ignoreStatuses:!0})):r.all&&Gd(this,e.agentId||null);break}case"vp_typing_start":{if(!r.vpId)break;let i=Wt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=Ad(this.yeaftVpTyping,i,r.vpId);break}case"vp_typing_end":{if(!r.vpId)break;let i=Wt(this,e.agentId||null,e.conversationId);if(!i)break;this.yeaftVpTyping=xd(this.yeaftVpTyping,i,r.vpId);break}case"vp_status_changed":{if(!r.vpId||!r.state)break;let i=r.sessionId||null,o=e.agentId||null,a=Fr(o,i,r.vpId),l={agentId:o,state:r.state,since:r.since||Date.now(),turnId:r.turnId||null,title:r.title||"",sessionId:i,vpId:r.vpId};if(this.vpStatuses={...this.vpStatuses,[a]:l},i&&Nr.has(r.state)){let c=dt(o,i);this.yeaftProcessingSessions={...this.yeaftProcessingSessions,...c?{[c]:!0}:{[i]:!0}}}else i&&this.clearYeaftSessionProcessingIfIdle(i,{agentId:o});this.restoreActiveYeaftSessionFromStatuses([l],o);break}case"vp_status_snapshot":{let i=Array.isArray(r.statuses)?r.statuses:[],o=r.sessionId;if(o==null){let a={...this.vpStatuses||{}};if(e.agentId)for(let[l,c]of Object.entries(a))(!c?.agentId||c.agentId===e.agentId)&&delete a[l];else for(let l of Object.keys(a))delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Fr(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}else{let a={...this.vpStatuses};for(let[l,c]of Object.entries(a))c&&c.sessionId===o&&(!e.agentId||!c.agentId||c.agentId===e.agentId)&&delete a[l];for(let l of i){if(!l||!l.vpId)continue;let c=l.sessionId||l.groupId||null,d=Fr(e.agentId||null,c,l.vpId);a[d]={agentId:e.agentId||null,state:l.state,since:l.since||Date.now(),turnId:l.turnId||null,title:l.title||"",sessionId:c,vpId:l.vpId}}this.vpStatuses=a}this.yeaftProcessingSessions=Th(this,e.agentId||null,i,o??null),this.restoreActiveYeaftSessionFromStatuses(i,e.agentId||null);break}case"yeaft_dream_snapshot":{let i=r&&r.snapshot,o=i&&typeof i.scope=="string"?i.scope:null;o&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[o]:{...i,receivedAt:Date.now()}});break}case"yeaft_dream_status":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamStatus(r);break}case"yeaft_dream_result":{let i=window.Pinia?.useVpStore?.()||window.__useVpStore&&window.__useVpStore();i&&i.applyDreamResult(r),r?.snapshot?.scope&&(this.yeaftDreamSnapshots={...this.yeaftDreamSnapshots,[r.snapshot.scope]:{...r.snapshot,receivedAt:Date.now()}});{let o=typeof r?.snapshot?.scope=="string"&&r.snapshot.scope?r.snapshot.scope:typeof r?.sessionId=="string"&&r.sessionId?`sessions/${r.sessionId}`:null;if(!o)break;let a=this.yeaftDreamLatest[o]||null;this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:{scope:o,phase:"result",status:r.skipped?"skipped":r.success?"success":"error",startedAt:a?.startedAt??null,finishedAt:Date.now(),mergedCount:typeof r.entriesCreated=="number"?r.entriesCreated:a?.mergedCount??null,error:r.skipped||r.success?null:r.error||"unknown",manual:typeof r?.manual=="boolean"?r.manual:a?.manual??null,durationMs:typeof r.durationMs=="number"?r.durationMs:a?.durationMs??null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:a?.llmCallCount??0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:a?.inputTokens??0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:a?.outputTokens??0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:a?.totalTokens??0,metrics:r.metrics||a?.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||a?.passBreakdown||null,isRunning:!1}},this._appendDreamEvent(o,{type:"dream_progress",phase:"result",sessionId:r.sessionId,status:r.skipped?"skipped":r.success?"success":"error",success:!!r.success,entriesCreated:typeof r.entriesCreated=="number"?r.entriesCreated:null,trigger:r.trigger||null,error:r.skipped||r.success?null:r.error||null,skipped:!!r.skipped,skippedReason:r.skippedReason||null,durationMs:typeof r.durationMs=="number"?r.durationMs:null,llmCallCount:typeof r.llmCallCount=="number"?r.llmCallCount:0,inputTokens:typeof r.inputTokens=="number"?r.inputTokens:0,outputTokens:typeof r.outputTokens=="number"?r.outputTokens:0,totalTokens:typeof r.totalTokens=="number"?r.totalTokens:0,metrics:r.metrics||null,passBreakdown:r.passBreakdown||r.metrics?.passBreakdown||null,ts:Date.now()})}break}case"dream_progress":{let i=r?.phase||"unknown",o=null;typeof r?.target=="string"&&r.target.includes("/")?o=r.target:typeof r?.sessionId=="string"&&r.sessionId?o=`sessions/${r.sessionId}`:o="*";let a=i==="done",l=i==="error"||r?.status==="error",c=!a&&!l,d=u=>{let f=this.yeaftDreamLatest[u]||null;return{scope:u,phase:i,status:l?"error":a?"success":"running",startedAt:f?.startedAt&&c?f.startedAt:r?.ts||f?.startedAt||Date.now(),finishedAt:a||l?r?.ts||Date.now():null,mergedCount:typeof r?.mergedCount=="number"?r.mergedCount:typeof r?.targets=="number"?r.targets:f?.mergedCount??null,error:l?r?.error||"unknown":null,manual:typeof r?.manual=="boolean"?r.manual:f?.manual??!1,durationMs:typeof r?.duration=="number"?r.duration:typeof r?.durationMs=="number"?r.durationMs:f?.durationMs??null,llmCallCount:typeof r?.llmCallCount=="number"?r.llmCallCount:f?.llmCallCount??0,inputTokens:typeof r?.inputTokens=="number"?r.inputTokens:f?.inputTokens??0,outputTokens:typeof r?.outputTokens=="number"?r.outputTokens:f?.outputTokens??0,totalTokens:typeof r?.totalTokens=="number"?r.totalTokens:f?.totalTokens??0,metrics:r?.metrics||f?.metrics||null,passBreakdown:r?.passBreakdown||r?.metrics?.passBreakdown||f?.passBreakdown||null,isRunning:c}};if(o==="*"){let u={...this.yeaftDreamLatest,"*":d("*")};for(let f of Object.keys(this.yeaftDreamLatest))f!=="*"&&(u[f]=d(f));this.yeaftDreamLatest=u}else this.yeaftDreamLatest={...this.yeaftDreamLatest,[o]:d(o)};this._appendDreamEvent(o,r);break}}},_appendDreamEvent(e,t){if(!e||!t)return;let s=Date.now(),n={...t,at:s},r=Array.isArray(this.yeaftDreamEvents?.[e])?this.yeaftDreamEvents[e]:[],i=l=>[l?.type||"",l?.phase||"",(l?.sessionId??l?.groupId)||"",l?.target||"",l?.ts||l?.at||""].join("|"),o=i(n);if(r.some(l=>i(l)===o))return;let a=[...r,n];a.length>ou&&a.splice(0,a.length-ou),this.yeaftDreamEvents={...this.yeaftDreamEvents,[e]:a}},fetchExpertRoleDefinitions(){if(this.expertRoleDefinitions)return;let e=this.currentAgent;e&&this.sendWsMessage({type:"get_expert_roles",agentId:e})},setYeaftSidebarEnabled(e){try{typeof localStorage<"u"&&localStorage.removeItem("yeaft-sidebar-enabled")}catch{}},vpCrudRequest(e,t){(!this._vpCrudPending||typeof this._vpCrudPending.get!="function")&&(this._vpCrudPending=new Map);let s="vpc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),r={create:"yeaft_vp_create",update:"yeaft_vp_update",delete:"yeaft_vp_delete",read:"yeaft_vp_read"}[e];if(!r)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let i={type:r,requestId:s};return e==="create"||e==="update"?i.payload=t||{}:i.vpId=t,new Promise(o=>{let a=setTimeout(()=>{this._vpCrudPending&&this._vpCrudPending.has(s)&&(this._vpCrudPending.delete(s),o({ok:!1,op:e,error:{code:"timeout",message:"vp_crud timeout"}}))},1e4);this._vpCrudPending.set(s,{resolve:l=>{clearTimeout(a),o(l)}}),this.sendWsMessage(i)})},sessionCrudRequest(e,t,s={}){(!this._sessionCrudPending||typeof this._sessionCrudPending.get!="function")&&(this._sessionCrudPending=new Map);let n="grc_"+Date.now().toString(36)+"_"+Math.random().toString(36).slice(2,8),i={list:"yeaft_list_sessions",create:"yeaft_create_session",rename:"yeaft_rename_session",update:"yeaft_update_session",update_config:"yeaft_update_session_config",archive:"yeaft_archive_session",delete:"yeaft_delete_session",add_member:"yeaft_session_add_member",remove_member:"yeaft_session_remove_member",set_default_vp:"yeaft_session_set_default_vp",reorder:"reorder_yeaft_sessions",scan_workdir:"yeaft_scan_workdir_sessions",restore:"yeaft_restore_session"}[e];if(!i)return Promise.resolve({ok:!1,op:e,error:{code:"bad_op",message:"unknown op: "+e}});let o={type:i,requestId:n};e==="create"?o.payload=t||{}:t&&typeof t=="object"&&Object.assign(o,t);let a=s&&s.agentId?s.agentId:null;a&&(o.agentId=a);let l=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();return l&&l.markPending(n,e),new Promise(c=>{let d=setTimeout(()=>{this._sessionCrudPending&&this._sessionCrudPending.has(n)&&(this._sessionCrudPending.delete(n),c({ok:!1,op:e,error:{code:"timeout",message:"group_crud timeout"}}))},1e4);this._sessionCrudPending.set(n,{resolve:u=>{clearTimeout(d),c(u)}}),this.sendWsMessage(o)})},markYeaftSessionUnread(e,t=null){if(!e)return!1;let s=Ie(this,e,t);if(!s)return!1;let n=yr(s,e);return this.currentView==="yeaft"&&this.yeaftActiveSessionFilter===e&&Ie(this,e)===s||this.yeaftUnreadSessionKeys?.[n]?!1:(this.yeaftUnreadSessionKeys={...this.yeaftUnreadSessionKeys,[n]:!0},!0)},markYeaftSessionRead(e,t=null){if(!e)return!1;let s=Ie(this,e,t);if(!s)return!1;let n=yr(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||au(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?Ie(this,n,t.agentId||null):this.currentAgent,i=!!n&&n===s&&!!r&&!!this.currentAgent&&r!==this.currentAgent,o=!!t.force||i;if(this.yeaftActiveSessionFilter=n,r&&n&&this.currentAgent!==r){this.selectAgent(r);let c=this.agents.find(d=>d.id===r);this.activateYeaftAgent(r,c||null)}else r&&n&&this.activateYeaftAgent(r);if(r&&n&&this.markYeaftSessionRead(n,r),!o&&n===s)return;let a=Pe(r,n),l=this.yeaftSessionHistoryState[a]||null;if(this.pruneYeaftMessageWindow(n),r&&n){this.yeaftSessionAgentById={...this.yeaftSessionAgentById||{},[n]:r};let c=this.yeaftConversationIdsByAgent?.[r]||null;c||(c=`yeaft-local-${r}-${Date.now()}`,this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[r]:c}),this.yeaftConversationId=c,this.messagesMap[c]||(this.messagesMap[c]=[]),this.currentView==="yeaft"&&(this.activeConversations=[c])}try{let c=window.Pinia?.useSessionsStore?.()||window.__useSessionsStore&&window.__useSessionsStore();c&&typeof c.setActive=="function"&&c.setActive(n,r||null);let d=c?.activeSessionKey||null;d?localStorage.setItem("lastViewedYeaftSession",d):localStorage.removeItem("lastViewedYeaftSession")}catch{}if(this.syncActiveYeaftHistoryLoad(),!l?.loading&&r&&n){let c=Number.isFinite(l?.latestSeq)?l.latestSeq:null,d={type:"yeaft_load_history",agentId:r,sessionId:n},u=!!l?.loaded,f=bo({sessionState:l,hasCachedSessionRows:!1,force:o});if(!f&&c!==null?d.afterSeq=c:d.limit=Or,!f&&u&&c===null){this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...l||{hasMore:!1,oldestSeq:null,count:0},loaded:!0,loading:!1,syncingAfterSeq:null}},this.syncActiveYeaftHistoryLoad();return}let p=null;if(!f&&u){if(l?.syncingAfterSeq===c)return;p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"delta",preserveLoaded:!0,latestSeq:c}),this.yeaftSessionHistoryState={...this.yeaftSessionHistoryState,[a]:{...this.yeaftSessionHistoryState[a],syncingAfterSeq:c}}}else p=this.beginYeaftHistoryLoad({agentId:r,sessionId:n,mode:"recent",preserveLoaded:!1,latestSeq:f?null:c});p&&(d.requestId=p.requestId),this.sendWsMessage(d)}},async switchYeaftModel(e,t=null,s=void 0){if(!e||!this.currentAgent)return;let n=t||null;if(n){let r={model:e};return s!==void 0&&(r.modelEffort=s||null),await this.sessionCrudRequest("update_config",{sessionId:n,config:r},{agentId:Ie(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()?iu:sa,dreamLimit:5,indexOnly:!0,search:this.yeaftDebugSearch})},250)},setYeaftDebugSessionFilter(e){e==null?this.yeaftDebugSessionFilter=null:this.yeaftDebugSessionFilter=String(e)},toggleSubAgentCardExpand(e){let t=this.yeaftSubAgentCards?.[e];t&&(this.yeaftSubAgentCards={...this.yeaftSubAgentCards,[e]:{...t,expanded:!t.expanded}})},loadSearchSettings(){return this.currentAgent?new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.load=e,this.sendWsMessage({type:"get_search_settings",agentId:this.currentAgent})}):(this.searchSettings={backend:"tavily",tavilyKeyConfigured:!1,tavilyKeyMasked:null,disableHtmlFallback:!1,loaded:!0},Promise.resolve(this.searchSettings))},updateSearchSettings(e){return this.currentAgent?new Promise(t=>{this._searchPending||(this._searchPending={}),this._searchPending.update=t,this.sendWsMessage({type:"update_search_settings",agentId:this.currentAgent,settings:e||{}})}):Promise.resolve({error:"no agent"})},loadTavilyUsage(){return this.currentAgent?(this.tavilyUsageLoading=!0,new Promise(e=>{this._searchPending||(this._searchPending={}),this._searchPending.usage=e,this.sendWsMessage({type:"get_tavily_usage",agentId:this.currentAgent})})):Promise.resolve(null)},loadYeaftMcpServers(){if(!this.currentAgent)return this.yeaftMcpServers=[],this.yeaftMcpRuntime={connected:!1,toolCount:0,perServer:[]},Promise.resolve({servers:[],runtime:this.yeaftMcpRuntime});this.yeaftMcpLoading=!0;let e=`mcp-list-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(t=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[e]=t,this.sendWsMessage({type:"yeaft_mcp_list",agentId:this.currentAgent,requestId:e})})},addYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-add-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_add",agentId:this.currentAgent,requestId:t,server:e||{}})})},removeYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rem-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_remove",agentId:this.currentAgent,requestId:t,name:e})})},reloadYeaftMcpServer(e){if(!this.currentAgent)return Promise.resolve({error:"no agent"});this.yeaftMcpLoading=!0;let t=`mcp-rel-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;return new Promise(s=>{this._mcpPending||(this._mcpPending={}),this._mcpPending[t]=s,this.sendWsMessage({type:"yeaft_mcp_reload",agentId:this.currentAgent,requestId:t,name:e||null})})},clearYeaftMessages(){let e=this.yeaftConversationId;e&&(Ae(this,e),delete this.messagesMap[e],delete this.processingConversations[e],delete this.executionStatusMap[e],delete this.refreshingSessionMap[e],this._closedAt&&delete this._closedAt[e],this._turnCompletedConvs?.delete(e)),this.yeaftConversationId=this.currentAgent?`yeaft-local-${this.currentAgent}-${Date.now()}`:`yeaft-local-${Date.now()}`,this.currentAgent&&(this.yeaftConversationIdsByAgent={...this.yeaftConversationIdsByAgent||{},[this.currentAgent]:this.yeaftConversationId}),this.messagesMap[this.yeaftConversationId]=[],this.activeConversations=[this.yeaftConversationId],this.yeaftSessionReady=!1,this.yeaftModel=null,this.yeaftAvailableModels=[],this.yeaftStatus=null,this._yeaftAskTerminalEvents={},this.yeaftDebugLoops=[],this.yeaftDebugTurnsById={},this.yeaftDebugTurnOrder=[],this.yeaftDebugHistoryLoading=!1,this.yeaftDebugHistoryError=null,this.yeaftDebugHistoryFetchedAt=0,this.yeaftDebugSearch="",this.yeaftDebugSessionFilter=null,this._yeaftDebugSearchTimer&&(clearTimeout(this._yeaftDebugSearchTimer),this._yeaftDebugSearchTimer=null),this._fetchYeaftDebugHistoryTimer&&(clearTimeout(this._fetchYeaftDebugHistoryTimer),this._fetchYeaftDebugHistoryTimer=null),this._yeaftDebugHistoryInFlightKey=null,this._yeaftDebugHistoryLatestListRequestId=null,this.yeaftReflectionCards={},this.yeaftSubAgentCards={},this.yeaftDreamLatest={},this.yeaftDreamEvents={},this.vpStatuses={},this.currentAgent&&this.sendWsMessage({type:"yeaft_reset",agentId:this.currentAgent})},togglePaneRightPanel(e,t=null){if(t&&this.isSplitMode){let s=this.panels.find(n=>n.id===t);if(s){s.activeRightPanel=s.activeRightPanel===e?null:e;return}}this.activeRightPanel=this.activeRightPanel===e?null:e},getPaneRightPanel(e){if(e&&this.isSplitMode){let t=this.panels.find(s=>s.id===e);if(t)return t.activeRightPanel}return this.activeRightPanel},setPaneRightPanel(e,t){if(e&&this.isSplitMode){let s=this.panels.find(n=>n.id===e);if(s){s.activeRightPanel=t;return}}this.activeRightPanel=t},applySessionCatalogSnapshot(e,t=null){let s=new Set;if(this.sessionCatalog=(Array.isArray(e)?e:[]).filter(n=>!n?.catalogKey||s.has(n.catalogKey)?!1:(s.add(n.catalogKey),!0)).map(n=>({...n})),Array.isArray(t)){this.sessionProjects=t.filter(r=>r?.id).map(r=>({...r,members:Array.isArray(r.members)?r.members.filter(i=>i?.agentId&&i?.sessionId):r.agentId?(r.sessionIds||[]).map(i=>({agentId:r.agentId,sessionId:i})):[]}));let n=new Map;for(let r of this.sessionProjects)for(let i of r.members)n.set(`${i.agentId}${i.sessionId}`,r.id);this.sessionCatalog=this.sessionCatalog.map(r=>r.runtimeProvider==="yeaft"?{...r,projectId:n.get(`${r.routeRef?.agentId}${r.routeRef?.sessionId}`)||null}:r)}this.sessionCatalogLoaded=!0},mutateProject(e,t={},s=null){let n=s||t.agentId||this.currentAgent||null;if(e==="move_session"&&!n)return Promise.resolve({ok:!1,error:{code:"missing_agent"}});let r=`project_${crypto.randomUUID()}`;return new Promise(i=>{let o=setTimeout(()=>{delete this.projectMutationRequests[r],i({ok:!1,error:{code:"timeout"}})},1e4);this.projectMutationRequests[r]={connectionGeneration:Number(this.chatHistoryConnectionGeneration||0),resolve:l=>{clearTimeout(o),i(l)}},this.sendWsMessage({type:"yeaft_project_mutation",...n?{agentId:n,targetAgentId:n}:{},requestId:r,op:e,...t})||(clearTimeout(o),delete this.projectMutationRequests[r],i({ok:!1,error:{code:"send_failed"}}))})},applyLegacyProjectSnapshot(e,t){if(!t||!Array.isArray(e))return;let s=this.sessionProjects.filter(r=>r.legacyAgentId!==t),n=e.filter(r=>r?.id).map(r=>({...r,id:`${t}${r.id}`,legacyProjectId:r.id,legacyAgentId:t,members:(r.sessionIds||[]).map(i=>({agentId:t,sessionId:i}))}));this.applySessionCatalogSnapshot(this.sessionCatalog,[...s,...n])},finishLegacyProjectMutation(e,t){if(!e?.requestId)return!1;let s=this.projectMutationRequests[e.requestId]||null;return!s||s.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&t&&this.applyLegacyProjectSnapshot(e.projects,t),s.resolve(e),!0)},finishProjectMutation(e){if(!e?.requestId)return!1;let t=this.projectMutationRequests[e.requestId]||null;return!t||t.connectionGeneration!==Number(this.chatHistoryConnectionGeneration||0)?!1:(delete this.projectMutationRequests[e.requestId],e.ok&&Array.isArray(e.projects)&&this.applySessionCatalogSnapshot(this.sessionCatalog,e.projects),t.resolve(e),!0)},toggleCatalogSessionPin(e){if(!e?.catalogKey||!e?.routeRef||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_ui_${crypto.randomUUID()}`,s=lo(this,t),n=!e.pinned;return e.pinned=n,this.sendWsMessage({type:"set_session_ui_metadata",requestId:t,catalogKey:e.catalogKey,routeRef:e.routeRef,pinned:n,sortRank:Number.isFinite(e.sortRank)?e.sortRank:null})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},renameCatalogSession({row:e,title:t}={}){if(!e?.routeRef||!t)return!1;let{runtimeProvider:s,agentId:n,sessionId:r}=e.routeRef;if(s==="yeaft")this.sessionCrudRequest("rename",{sessionId:r,name:t},{agentId:n});else if(s==="claude-code"||s==="copilot")this.renameChatSession(r,t,n);else return!1;return!0},reorderCatalogSessions(e){if(!Array.isArray(e)||e.length===0||Object.keys(this.sessionCatalogMutationRequests).length>0)return!1;let t=`session_order_${crypto.randomUUID()}`,s=lo(this,t);return this.sessionCatalog=e.map((r,i)=>({...r,sortRank:i})),this.sendWsMessage({type:"reorder_session_catalog",requestId:t,sessions:this.sessionCatalog.map((r,i)=>({catalogKey:r.catalogKey,routeRef:r.routeRef,pinned:!!r.pinned,sortRank:i}))})?!0:(this.sessionCatalog=s,delete this.sessionCatalogMutationRequests[t],!1)},finishSessionCatalogMutation(e){return Tl(this,e)},openCatalogSession(e){if(!e?.catalogKey||!e.routeRef)return!1;let{runtimeProvider:t,agentId:s,sessionId:n}=e.routeRef;return this.activeCatalogKey=e.catalogKey,t==="yeaft"?(this.enterYeaft(s,{deferBootstrap:!0}),this.setActiveSessionFilter(n,{agentId:s,force:!0}),!0):t!=="claude-code"&&t!=="copilot"?!1:(this.currentView==="yeaft"&&this.leaveYeaft(),this.selectConversation(n,s),!0)},requestChatHistory(e,{mode:t="recent",turns:s=null,beforeId:n=null,afterMessageId:r=null}={}){if(!e)return null;let i=Rs(e);if(this.chatHistoryRequestIdSupported!==!0&&this.chatHistoryRequests[i]?.loading)return null;let o=n??r??null,a=this.beginChatHistoryRequest(e,t,o);return this.sendWsMessage({type:"sync_messages",conversationId:e,...s!=null?{turns:s}:{},...n!=null?{beforeId:n}:{},...r!=null?{afterMessageId:r}:{},requestId:a})?a:(Pl(this,i,a,"send_failed"),null)},beginChatHistoryRequest(e,t="recent",s=null){return Ml(this,e,t,s)},isCurrentChatHistoryResponse(e){if(!e?.conversationId||!e?.requestId||!e?.catalogKey)return!1;let t=Rs(e.conversationId);if(e.catalogKey!==t)return!1;let s=this.chatHistoryRequests[t];return!!s&&s.loading===!0&&s.requestId===e.requestId&&Number(s.connectionGeneration||0)===Number(this.chatHistoryConnectionGeneration||0)},finishChatHistoryRequest(e){if(!this.isCurrentChatHistoryResponse(e))return!1;let t=this.chatHistoryRequests[e.catalogKey];return this.chatHistoryRequests[e.catalogKey]={...t,loading:!1},!0},isRefreshingSession(e){return e?!!this.refreshingSessionMap[e]:this.refreshingSession},setRefreshingSession(e,t){e&&(this.refreshingSessionMap[e]=t),this.refreshingSession=t},enterBtwMode(){this.btwMode=!0,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},sendBtwQuestion(e){this.currentConversation&&(this.btwMessages.push({role:"user",content:e}),this.btwMessages.push({role:"assistant",content:""}),this.btwLoading=!0,this.sendWsMessage({type:"btw_question",conversationId:this.currentConversation,question:e,btwSessionId:this.btwSessionId}))},closeBtw(){this.btwMode=!1,this.btwMessages=[],this.btwLoading=!1,this.btwSessionId=null},appendBtwDelta(e){let t=this.btwMessages[this.btwMessages.length-1];t&&t.role==="assistant"&&(t.content+=e)},addSubagent(e,t){this.subagents[e]||(this.subagents[e]={}),this.subagents[e][t.id]={id:t.id,slug:t.slug||t.id,type:t.type||"Task",description:t.description||"",parentToolUseId:t.parentToolUseId||null,status:"running",startTime:Date.now(),messages:[],toolCallCount:0},e===this.currentConversation&&this.activeRightPanel!=="subagents"&&(this.activeRightPanel="subagents")},appendSubagentMessage(e,t,s){let n=this.subagents[e];if(!n||!n[t])return;let r=n[t];if(s?.type==="tool"){r.toolCallCount=Number(r.toolCallCount||0)+1;return}s?.type==="text"&&r.messages.push(s)},completeSubagent(e,t){let s=this.subagents[e];!s||!s[t]||(s[t].status="completed")},sendWsMessage(e){return Kl(this,e)},parseWsMessage(e){return Yl(this,e)},connect(){Gl(this)},ensureConnected(){return bn(this)},scheduleReconnect(){Ql(this)},manualReconnect(){Xl(this)},startHeartbeat(){Zl(this)},stopHeartbeat(){Jl(this)},setupVisibilityHandler(){ec(this)},handleMessage(e){zc(this,e)},getOrCreateExecutionStatus(e){return Lo(this,e)},handleAssistantOutputFrame(e,t){$c(this,e,t)},handleClaudeOutput(e,t){this.handleAssistantOutputFrame(e,t)},addMessageToConversation(e,t){wr(this,e,t)},appendToAssistantMessageForConversation(e,t,s){lc(this,e,t,s)},finishStreamingForConversation(e,t){cc(this,e,t)},sweepStaleStreamingForConversation(e){dc(this,e)},appendToAssistantMessage(e){this.appendToAssistantMessageForConversation(this.currentConversation,e)},finishStreaming(){this.finishStreamingForConversation(this.currentConversation)},addMessage(e){this.addMessageToConversation(this.currentConversation,e)},loadHistoryMessages(e){uc(this,e)},formatDbMessage(e){return wo(e)},formatDbMessageForHistoryHydration(e){return fc(e)},selectAgent(e){return ed(this,e)},createConversation(e,t=null,s=null,n=void 0){td(this,e,t,s,n)},resumeConversation(e,t,s=null,n=null,r=null){sd(this,e,t,s,n,r)},selectConversation(e,t){nd(this,e,t)},updateConversationSettings(e,t){qo(this,e,t)},toggleConversationMcp(e,t){rd(this,e,t)},deleteConversation(e,t){od(this,e,t)},closeSession(e,t){id(this,e,t)},appendColumn(e){dd(this,e)},removeColumn(e){ud(this,e)},sendMessageToConversation(e,t,s=[],n={}){pd(this,e,t,s,n)},cancelExecutionForConversation(e){fd(this,e)},addPanel(){if(this.panels.length>=3)return;let e=(t,s)=>({id:t,conversationId:s,activeRightPanel:null});if(this.panels.length===0){let t=localStorage.getItem("splitPanesSaved");if(t){try{let s=JSON.parse(t);if(Array.isArray(s)&&s.length>=2){let n=new Set(this.conversations.map(i=>i.id)),r=s.filter(i=>i&&typeof i.id=="string").map(i=>({...e(i.id,null),conversationId:i.conversationId&&n.has(i.conversationId)?i.conversationId:null}));if(r.length>=2){this.panels=r,this.activePanelId=r[0].id;for(let i of r)i.conversationId&&!this.activeConversations.includes(i.conversationId)&&this.activeConversations.push(i.conversationId),i.conversationId&&!this.messagesMap[i.conversationId]&&(this.messagesMap[i.conversationId]=[],this.requestChatHistory(i.conversationId,{mode:"recent",turns:5}));localStorage.removeItem("splitPanesSaved"),this.saveOpenSessions();return}}}catch{}localStorage.removeItem("splitPanesSaved")}this.panels=[e("panel-0",this.currentConversation),e("panel-1",null)],this.activePanelId="panel-0"}else{let t="panel-"+Date.now();this.panels.push(e(t,null))}this.saveOpenSessions()},removePanel(e){let t=this.panels.findIndex(s=>s.id===e);if(!(t<0)){if(this.panels.splice(t,1),this.panels.length<=1){let s=this.panels[0];s?.conversationId&&(this.activeConversations=[s.conversationId]),this.panels=[],this.activePanelId=null}else this.activePanelId===e&&(this.activePanelId=this.panels[0]?.id||null);this.saveOpenSessions()}},setPanelConversation(e,t){let s=this.panels.find(n=>n.id===e);s&&(s.conversationId=t,t&&!this.activeConversations.includes(t)&&this.activeConversations.push(t),t&&!this.messagesMap[t]&&(this.messagesMap[t]=[],this.requestChatHistory(t,{mode:"recent",turns:5})),this.saveOpenSessions())},setActivePanel(e){this.activePanelId=e},splitToPanel(e){if(!e)return;let t=(s,n)=>({id:s,conversationId:n,activeRightPanel:null});if(this.panels.length===0)this.panels=[t("panel-0",this.currentConversation),t("panel-"+Date.now(),e)],this.activePanelId=this.panels[1].id;else if(this.panels.length>=3)this.panels[this.panels.length-1].conversationId=e,this.activePanelId=this.panels[this.panels.length-1].id;else{let s="panel-"+Date.now();this.panels.push(t(s,e)),this.activePanelId=s}this.activeConversations.includes(e)||this.activeConversations.push(e),this.messagesMap[e]||(this.messagesMap[e]=[],this.requestChatHistory(e,{mode:"recent",turns:5})),this.saveOpenSessions()},isInAnyPanel(e){return this.panels.some(t=>t.conversationId===e)},setSessionPinned(e,t,s={}){if(!e)return;let n=s&&s.agentId?s.agentId:null,r=n?!!ps()?.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=Ie(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?ps()?.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||Ie(this,e);if(Object.values(this.activeVpTurns||{}).some(a=>pt(a,e,n))||!s&&Object.values(this.vpStatuses||{}).some(l=>pt(l,e,n)&&Nr.has(l?.state)))return;let i=dt(n,e),o={...this.yeaftProcessingSessions||{}};i&&delete o[i],qr(this,e,n)&&delete o[e],this.yeaftProcessingSessions=o},sendMessage(e,t=[],s={}){ad(this,e,t,s)},cancelExecution(){ld(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],Gd(this,this.currentAgent)},cancelYeaftSession(e){let t=Ie(this,e);!t||!e||(this.sendWsMessage({type:"yeaft_abort_all",agentId:t,sessionId:e}),this.activeVpTurns=Object.fromEntries(Object.entries(this.activeVpTurns||{}).filter(([,s])=>!pt(s,e,t))),this.stoppingVpTurnIds=Object.fromEntries(Object.entries(this.stoppingVpTurnIds||{}).filter(([s])=>this.activeVpTurns?.[s])),this.vpStatuses=Object.fromEntries(Object.entries(this.vpStatuses||{}).filter(([,s])=>!pt(s,e,t))),this.clearYeaftSessionProcessingIfIdle(e,{agentId:t,ignoreStatuses:!0}))},cancelVpTurn(e,{sessionId:t=null,vpId:s=null}={}){let n=Ie(this,t);if(!n||!e)return;let r=Bs(this,n,e);this.stoppingVpTurnIds={...this.stoppingVpTurnIds,[r]:Date.now()};let i={type:"yeaft_abort_turn",agentId:n,turnId:e};t&&(i.sessionId=t),s&&(i.vpId=s),this.sendWsMessage(i)},cancelVpTurnForSession(e,t=null){if(!e)return!1;let s=t||this.yeaftActiveSessionFilter||null;if(!s)return!1;let n=Ie(this,s);if(!n)return!1;let r=this.activeVpTurns||{},i=null,o=-1/0;for(let[a,l]of Object.entries(r)){if(!l||l.vpId!==e||!pt(l,s,n))continue;let c=typeof l.startedAt=="number"?l.startedAt:0;c>=o&&(o=c,i=a)}if(!i){let a=this.vpStatuses?.[Fr(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){cd(this,e,t,s)},refreshAgents(){gd(this)},refreshConversation(){md(this)},restartAgent(e){hd(this,e)},upgradeAgent(e){vd(this,e)},loadMoreMessages(){if(this.currentView==="yeaft"||this.loadingMoreMessages||!this.hasMoreMessages||!this.currentConversation)return;this.loadingMoreMessages=!0;let e=this._loadMoreGeneration=(this._loadMoreGeneration||0)+1,s=(this.messagesMap[this.currentConversation]||[]).find(i=>i.dbMessageId),n=this.currentConversation,r=s?.dbMessageId??null;this.requestChatHistory(n,{mode:"older",turns:5,beforeId:r}),setTimeout(()=>{this._loadMoreGeneration===e&&this.loadingMoreMessages&&this.currentConversation===n&&(this.loadingMoreMessages=!1)},1e4)},reloadYeaftMessages(){if(this.currentView!=="yeaft")return!1;let e=us(this),t=Ie(this,e);if(!t)return!1;let s=Pe(t,e),n=this.yeaftConversationId,r=this.beginYeaftHistoryLoad({agentId:t,sessionId:e,mode:"recent",preserveLoaded:!1});if(!r)return!1;let i=An();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[s]:i};let o={type:"yeaft_load_history",agentId:t,limit:Or,sessionId:e,requestId:r.requestId,perfTraceId:i};return Xe(this,{traceId:i,phase:"history.request_send",agentId:t,sessionId:e,messageType:o.type,bytes:JSON.stringify(o).length,detail:{mode:"manual-reload",limit:Or}}),this.sendWsMessage(o),!0},loadMoreYeaftHistory(e=Ln()){if(this.currentView!=="yeaft"||this.yeaftLoadingMoreHistory||!this.yeaftHasMoreHistory||this.yeaftOldestLoadedSeq==null)return;let t=us(this),s=Ie(this,t);if(!s)return;let n=Math.min(50,Math.max(1,Number.isFinite(e)?Math.floor(e):Ln())),r=Pe(s,t),i=this.beginYeaftHistoryLoad({agentId:s,sessionId:t,mode:"older",preserveLoaded:!0,latestSeq:this.yeaftSessionHistoryState[r]?.latestSeq??null});if(!i)return;let o=An();this.yeaftHistoryPerfTraceBySession={...this.yeaftHistoryPerfTraceBySession||{},[r]:o};let a={type:"yeaft_load_more_history",agentId:s,sessionId:t,requestId:i.requestId,beforeSeq:this.yeaftOldestLoadedSeq,turns:n,perfTraceId:o};Xe(this,{traceId:o,phase:"history_more.request_send",agentId:s,sessionId:t,messageType:a.type,bytes:JSON.stringify(a).length,detail:{beforeSeq:a.beforeSeq,turns:a.turns}}),this.sendWsMessage(a)},checkPendingRecovery(){Rl(this)},performRecovery(){_l(this)},dismissRecovery(){El(this)},autoRestoreConversation(e){Dl(this,e)},saveOpenSessions(){Es(this)},getLastSession(){return $l(this)},clearLastSession(){Vl(this)},listHistorySessions(e){Fl(this,e)},listFolders(){return Ol(this)},listFoldersForAgent(e,t){return Hl(this,e,t)},listModelsForAgent(e,t){return ql(this,e,t)},listHistorySessionsForAgent(e,t,s){Nl(this,e,t,s)},async loadGlobalSessions(e=20){return Bl(this,e)},async deleteGlobalSession(e){return Wl(this,e)},findAgentForSession(e){return uo(this,e)},isSessionResumable(e){return Ul(this,e)},_isRecentlyClosed(e){return rs(this,e)},_startProcessingWatchdog(e){Ls(this,e)},_resetProcessingWatchdog(e){kr(this,e)},_stopProcessingWatchdog(e){Ae(this,e)},startRefreshTimeout(e){let t=e||this.currentConversation;t&&(this._refreshTimeouts||(this._refreshTimeouts={}),this._refreshTimeouts[t]&&clearTimeout(this._refreshTimeouts[t]),this._refreshTimeouts[t]=setTimeout(()=>{this.setRefreshingSession(t,!1),delete this._refreshTimeouts[t]},1e4))},toggleTheme(){this.theme=this.theme==="dark"?"light":"dark",this.themeFollowSystem=!1,localStorage.setItem("theme",this.theme),document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light")},initTheme(){if(document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"),this.themeFollowSystem&&typeof window<"u"&&window.matchMedia){let e=window.matchMedia("(prefers-color-scheme: dark)"),t=s=>{this.themeFollowSystem&&(this.theme=s.matches?"dark":"light",document.documentElement.setAttribute("data-theme",this.theme),document.documentElement.classList.toggle("light",this.theme==="light"))};e.addEventListener?e.addEventListener("change",t):e.addListener&&e.addListener(t)}},loadModelsDevRegistry({forceRefresh:e=!1}={}){let t=this.modelsDevRegistry.loaded&&!this.modelsDevRegistry.error&&Date.now()-this.modelsDevRegistry.fetchedAt<36e5;if(!e&&t)return Promise.resolve(this.modelsDevRegistry);let s=this.currentAgent;if(!s)return Promise.resolve(this.modelsDevRegistry);if(this._modelsDevPending&&(!e||this._modelsDevPending.force))return new Promise(n=>this._modelsDevPending.resolvers.push(n));if(this._modelsDevPending){let n=this._modelsDevPending;this._modelsDevPending=null,n.timer&&clearTimeout(n.timer);for(let r of n.resolvers)r(this.modelsDevRegistry)}return new Promise(n=>{let r={resolvers:[n],force:e,timer:null};this._modelsDevPending=r;try{this.sendWsMessage({type:"get_models_dev_registry",agentId:s,forceRefresh:e})}catch{this._modelsDevPending===r&&(this._modelsDevPending=null),n(this.modelsDevRegistry);return}r.timer=setTimeout(()=>{if(this._modelsDevPending===r){this._modelsDevPending=null;for(let i of r.resolvers)i(this.modelsDevRegistry)}},2e4)})},changeLocale(e){if(this.locale=e,hn(e),this.currentAgent)try{this.sendWsMessage({type:"update_llm_config",agentId:this.currentAgent,config:{language:e}})}catch{}},async fetchCustomExpertRoles(){let e=_e();try{let t={};e.token&&(t.Authorization=`Bearer ${e.token}`);let s=await fetch("/api/expert-roles/custom",{headers:t});if(s.ok){let n=await s.json();this.customExpertRoles=n.roles||[]}}catch{}},async createCustomExpertRole(e){let t=_e();try{let s={"Content-Type":"application/json"};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch("/api/expert-roles/custom",{method:"POST",headers:s,body:JSON.stringify(e)});if(n.ok){let r=await n.json();return this.customExpertRoles.push(r.role),r.role}else{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to create custom expert role")}}catch(s){throw s}},async updateCustomExpertRole(e,t){let s=_e();try{let n={"Content-Type":"application/json"};s.token&&(n.Authorization=`Bearer ${s.token}`);let r=await fetch(`/api/expert-roles/custom/${e}`,{method:"PUT",headers:n,body:JSON.stringify(t)});if(r.ok){let i=await r.json(),o=this.customExpertRoles.findIndex(a=>a.id===e);return o!==-1&&(this.customExpertRoles[o]=i.role),i.role}else{let i=await r.json().catch(()=>({}));throw new Error(i.error||"Failed to update custom expert role")}}catch(n){throw n}},async deleteCustomExpertRole(e){let t=_e();try{let s={};t.token&&(s.Authorization=`Bearer ${t.token}`);let n=await fetch(`/api/expert-roles/custom/${e}`,{method:"DELETE",headers:s});if(n.ok)return this.customExpertRoles=this.customExpertRoles.filter(r=>r.id!==e),!0;{let r=await n.json().catch(()=>({}));throw new Error(r.error||"Failed to delete custom expert role")}}catch(s){throw s}},toggleWorkbench(){this.workbenchExpanded=!this.workbenchExpanded,this.workbenchExpanded||(this.workbenchMaximized=!1)},toggleSidebar(){this.sidebarCollapsed=!this.sidebarCollapsed},toggleSessionSidebar(){this.sessionSidebarOpen=!this.sessionSidebarOpen},closeSessionSidebar(){this.sessionSidebarOpen=!1},toggleWorkbenchMaximized(){this.workbenchMaximized=!this.workbenchMaximized},renameChatSession(e,t,s=null){let n=t&&t.trim()?t.trim():"";n?this.customConversationTitles[e]=n:delete this.customConversationTitles[e],this.sendWsMessage({type:"update_conversation_settings",conversationId:e,...s?{agentId:s}:{},title:n})},openFileInExplorer(e){this.currentConversation&&(this.workbenchExpanded=!0,window.dispatchEvent(new CustomEvent("open-file-in-explorer",{detail:{filePath:e,conversationId:this.currentConversation}})))},logout(){_e().logout(),this.authenticated=!1,this.sessionKey=null,this.agents=[],this.currentAgent=null,this.currentAgentInfo=null,this.yeaftStatusByAgent={},this._yeaftRetiredCatalogEpochsByAgent={},this.conversations=[],this.activeConversations=[],this.messagesMap={},this.conversationTitles={},this.customConversationTitles={},this.processingConversations={},this.executionStatusMap={},this.workbenchExpanded=!1,this.subagents={},this.activeSubagentId=null,this.activeRightPanel=null,this.pinnedSessions=[],this.clearWorkCenterBrowserState(),this.ws&&this.ws.close()}}})});function ia(e,t){!e||typeof e.handleYeaftOutput!="function"||!t||e.handleYeaftOutput({event:t})}function Wh(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 aa(e){if(!e)return Ut[0];let t=String(e).toLowerCase();return Bh[t]||Ut[Wh(t)%Ut.length]}function Uh(e){return aa(e).background}function jh(e){return aa(e).foreground}function oa(){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 zh(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 Nh,Ut,Bh,Pw,yt,Ws=F(()=>{({defineStore:Nh}=Pinia);Ut=[{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)"}],Bh=Object.freeze({steve:Ut[8],ada:Ut[3],linus:Ut[0],martin:Ut[4]}),Pw=Ut.map(e=>e.background);yt=Nh("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?oa().startsWith("zh")&&s.displayNameZh?s.displayNameZh:s.displayName||s.vpId||t:t},vpDescription:e=>t=>zh(e.vps[t],oa()),vpInitial:e=>t=>{let s=e.vps[t],n=oa().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:Uh(t)},vpTextColor:()=>e=>jh(e),vpAvatarMotif:()=>e=>aa(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(ia(s,{type:"dream_progress",phase:"start",groupId:e,manual:!0,trigger:"manual",source:"header-button",ts:n}),!s||typeof s.sendWsMessage!="function"){ia(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&&ia(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 la(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 Wr(e){return!e||typeof e!="object"?0:la(e.lastMessageAt)||la(e.updatedAt)||la(e.createdAt)||0}function ca(e,t){let s=Wr(t)-Wr(e);return s!==0?s:String(e?.id||"").localeCompare(String(t?.id||""))}function du(e){return[...Array.isArray(e)?e:[]].sort(ca)}var Ur=F(()=>{});function uu(){try{if(typeof localStorage>"u")return{};let e=JSON.parse(localStorage.getItem(mu)||"{}");return e&&typeof e=="object"?e:{}}catch{return{}}}function Kh(e){try{typeof localStorage<"u"&&localStorage.setItem(mu,JSON.stringify(e&&typeof e=="object"?e:{}))}catch{}}function pu(){try{return typeof localStorage>"u"?[]:Vn(JSON.parse(localStorage.getItem(hu)||"[]"))}catch{return[]}}function Yh(e){try{typeof localStorage<"u"&&localStorage.setItem(hu,JSON.stringify(Vn(e)))}catch{}}function vu(e,t){return`${e||""}${t||""}`}function Pt(e){return e&&e.agentId&&e.id?vu(e.agentId,e.id):""}function bt(e,t){return t?e?vu(e,t):String(t):""}function Gh(e){return typeof e=="string"?e:String(e||"")}function st(e,t,s=null){let n=Gh(t);if(!n)return"";let r=bt(s,n),i=r?e.sessions[r]:null;if(i&&(s||i.agentId||e.inventoryIdentityMode==="legacy-bare"))return r;if(s){let c=e.sessions[n];return e.inventoryIdentityMode==="legacy-bare"&&c&&!c.agentId?n:""}let o=e.sessions[n];if(o){if(o.agentId||e.inventoryIdentityMode==="legacy-bare")return n;let c=e.activeSessionKey?e.sessions[e.activeSessionKey]:null;return c?.agentId&&c.id===n?e.activeSessionKey:""}if(e.activeSessionKey&&e.sessions[e.activeSessionKey]?.id===n)return e.activeSessionKey;let a=e.sessionOrder.filter(c=>e.sessions[c]?.id===n),l=Fn();if(l?.currentAgent){let c=a.find(d=>e.sessions[d]?.agentId===l.currentAgent);if(c)return c}return a[0]||""}function da(e,t,s=null){return st(e,t,s)||""}function ua(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 Qh(e){let t=e._preferredExactSessionIdentity||null;if(!t)return!1;e._preferredExactSessionIdentity=null;let s=e.sessions[t.key]||null,n=Fn(),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=Pn(localStorage.getItem("lastViewedYeaftSession")||"");o.agentId===t.agentId&&o.sessionId===t.sessionId&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function jr(e){let t=e._retiredBareActiveSessionId||null;if(!t)return!1;let s=Fn();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")||"";Pn(r).sessionId===t&&localStorage.removeItem("lastViewedYeaftSession")}catch{}return!0}function Vn(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 pa(e,t){let s=Vn(e),n=new Set(s),r=Vn(t).filter(o=>n.has(o)),i=new Set(r);return[...r,...s.filter(o=>!i.has(o))]}function zr(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 fu(e){return!e||typeof e!="object"?!1:e.running===!0||e.active===!0||e.isActive===!0||e.isRunning===!0}function gu(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 Fn(){try{if(typeof window<"u"&&window.Pinia&&typeof window.Pinia.useChatStore=="function")return window.Pinia.useChatStore()}catch{}return null}var mu,hu,Xh,yu,bu=F(()=>{Ur();Rn();mu="yeaft-session-order-by-agent",hu="yeaft-session-order-global";({defineStore:Xh}=Pinia);yu=Xh("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=Fn(),n=s&&Array.isArray(s.pinnedSessions)?new Set(s.pinnedSessions):new Set;for(let d of t)d&&d.id&&d.pinned&&n.add(d.id);let r=[],i=[];for(let d of t)d.pinned||!d.agentId&&n.has(d.id)?r.push(d):i.push(d);let o=d=>[...d].sort((u,f)=>{let p=Number.isFinite(u?.sortOrder)?u.sortOrder:Number.MAX_SAFE_INTEGER,g=Number.isFinite(f?.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER;return p!==g?p-g:ca(u,f)}),a=[...o(r),...o(i)],l=pu();if(l.length===0)return a;let c=new Map(l.map((d,u)=>[d,u]));return a.sort((d,u)=>{let f=c.has(Pt(d))?c.get(Pt(d)):Number.MAX_SAFE_INTEGER,p=c.has(Pt(u))?c.get(Pt(u)):Number.MAX_SAFE_INTEGER;return f!==p?f-p:0})},sessionCount(e){return e.sessionOrder.length},sessionById:e=>(t,s=null)=>{let n=st(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){ua(this);let o={...this.sessions},a=new Set;for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);a.add(g),o[g]=this._normalize(p,t,zr(this.sessions[g]))}for(let p of this.sessionOrder){let g=this.sessions[p];g&&g.agentId===t&&!a.has(p)&&delete o[p]}let l=this.sessionOrder.filter(p=>o[p]),c=new Set(l),d=[];for(let p of n){if(!p||!p.id)continue;let g=bt(t,p.id);o[g]&&!c.has(g)&&d.push(g)}this.sessions=o;let u=[...l,...d],f=pu();if(f.length>0){let p=new Map(u.map(A=>[Pt(o[A]),A]).filter(([A])=>A)),g=f.map(A=>p.get(A)).filter(Boolean),b=new Set(g);u=[...g,...u.filter(A=>!b.has(A))];let h=new Map(f.map((A,w)=>[A,w]));for(let A of u){let w=Pt(o[A]);w&&h.has(w)&&(o[A]={...o[A],sortOrder:h.get(w)})}}if(t&&f.length===0){let p=uu(),g=Vn(p[t]);if(g.length>0){let b=g.map(m=>bt(t,m)),h=new Set(b),A=pa(u.filter(m=>o[m]?.agentId===t),b),w=this.sessionOrder.some(m=>o[m]?.agentId===t),S=0;w?u=this.sessionOrder.filter(m=>o[m]).map(m=>o[m]?.agentId===t?A[S++]:m).concat(A.slice(S)):u=u.map(m=>o[m]?.agentId===t?A[S++]:m);let y=new Map(b.map((m,v)=>[m,v]));for(let m of A)o[m]&&h.has(m)&&(o[m]={...o[m],sortOrder:y.get(m)})}}this.sessionOrder=u}else{if(this.inventoryIdentityMode==="agent-scoped")return;if(Object.values(this.sessions).some(c=>c&&c.agentId)){this.inventoryIdentityMode="agent-scoped";return}let a={},l=[];for(let c of n){if(!c||!c.id)continue;let d=bt(null,c.id);a[d]=this._normalize(c,null,zr(this.sessions[d])),l.push(d)}this.sessions=a,this.sessionOrder=l,this.inventoryIdentityMode="legacy-bare"}s||(r=Qh(this)||jr(this)),this.lastSnapshotAt=Date.now();let i=Fn();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?st(this,o,t):"",c=l?this.sessions[l]:null,d=c&&(!t||c.agentId===t),u=this.sessionOrder.filter(S=>this.sessions[S]&&(!t||this.sessions[S].agentId===t)&&this.sessions[S].running).sort((S,y)=>gu(this.sessions[y])-gu(this.sessions[S]))[0]||null,f=u?this.sessions[u]?.id:null,p=this.sessionList[0]||null,g=p?.id||null,b=g?st(this,g,p?.raw?.agentId||null):"",h=f||(d?c.id:null)||g,A=u||(d?l:"")||b||da(this,h,t),w=this.activeSessionKey?this.sessions[this.activeSessionKey]?.agentId:null;if(this.activeSessionId&&!st(this,this.activeSessionId,w)?(this.activeSessionId=h,this.activeSessionKey=A||null):!this.activeSessionId&&this.sessionOrder.length>0&&!this._retiredBareActiveSessionId?(this.activeSessionId=h,this.activeSessionKey=A||null):this.activeSessionId&&(this.activeSessionKey=da(this,this.activeSessionId,w)||this.activeSessionKey),i&&!this._retiredBareActiveSessionId){let S=this.activeSessionId||h,y=null;if((i.yeaftActiveSessionFilter&&!st(this,i.yeaftActiveSessionFilter)||!i.yeaftActiveSessionFilter&&S)&&(y=S),y){let m=da(this,y),v=m&&this.sessions[m]?.agentId||null;i.currentView==="yeaft"&&typeof i.setActiveSessionFilter=="function"?i.setActiveSessionFilter(y,{agentId:v,force:!0}):i.yeaftActiveSessionFilter=y,this.activeSessionKey=m||this.activeSessionKey}}}if(i&&typeof i.applyServerPinSnapshot=="function"){let o=new Set;for(let l of n){if(!l||!l.id)continue;let c=bt(t,l.id),d=this.sessions[c];d&&d.pinned&&o.add(l.id)}let a=l=>{let c=st(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)ua(this);else if(this.inventoryIdentityMode!=="legacy-bare")return;let r=st(this,s,n)||bt(n,s),i=this.sessions[r];if(!i){let o=this._normalize({id:s,name:e.name||s,roster:Array.isArray(e.roster)?e.roster:[],defaultVpId:e.defaultVpId||null},n);this.sessions[r]=o,this.sessionOrder.push(r),jr(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},jr(this)},applyCrudResult(e,t=null){if(!e)return;this.lastCrudResult={...e,at:Date.now()},e.requestId&&this.pending[e.requestId]&&delete this.pending[e.requestId];let s=e.session||e.group||null,n=t||e.agentId||s?.agentId||null;e.ok&&e.op==="list"&&Array.isArray(e.sessions)&&this.applySnapshot(e.sessions,n),e.ok&&(e.op==="create"||e.op==="restore")&&s&&s.id&&this.applySnapshotUpsert(s,n)&&this.setActive(s.id,n);let r=e.sessionId||e.groupId,i=this.inventoryIdentityMode==="legacy-bare",o=r&&(n||i)?st(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)ua(this);else if(this.inventoryIdentityMode!=="legacy-bare")return"";let n=st(this,e.id,s)||bt(s,e.id),r=!!this.sessions[n],i=this.sessions[n]||{};return this.sessions[n]={...i,...this._normalize(e,s,zr(i))},r||this.sessionOrder.push(n),jr(this),n},setActive(e,t=null){let s=st(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=pa(s,t.map(l=>bt(e,l)));if(n.length===0)return[];let r=new Map(n.map((l,c)=>[l,c])),i=0;this.sessionOrder=this.sessionOrder.map(l=>this.sessions[l]?.agentId===e?n[i++]:l);for(let l of n)this.sessions[l]={...this.sessions[l],sortOrder:r.get(l)};let o=uu(),a=n.map(l=>this.sessions[l]?.id).filter(Boolean);return o[e]=a,Kh(o),a},reorderSessionsGlobally(e){let t=this.sessionOrder.map(a=>Pt(this.sessions[a])).filter(Boolean),s=pa(t,e);if(s.length===0)return[];let n=new Map(this.sessionOrder.map(a=>[Pt(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=Pt(this.sessions[a]);l&&o.has(l)&&(this.sessions[a]={...this.sessions[a],sortOrder:o.get(l)})}return Yh(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=st(this,e,s);!e||!n||!this.sessions[n]||(this.sessions[n]={...this.sessions[n],pinned:!!t})},markPending(e,t){e&&(this.pending[e]=t)},clearLastResult(){this.lastCrudResult=null},resetInventory(){this.sessions={},this.sessionOrder=[],this.activeSessionId=null,this.activeSessionKey=null,this.inventoryIdentityMode="empty",this._retiredBareActiveSessionId=null,this._preferredExactSessionIdentity=null,this.lastSnapshotAt=0},beginInventoryCommit(e=null,t=null){if(this.resetInventory(),e&&t){let s=bt(t,e);this.activeSessionId=e,this.activeSessionKey=s,this._preferredExactSessionIdentity={sessionId:e,agentId:t,key:s}}else e&&(this._retiredBareActiveSessionId=e)},_normalize(e,t=null,s=!1){return{id:e.id,name:e.name||e.id,roster:Array.isArray(e.roster)?e.roster.slice():[],defaultVpId:e.defaultVpId||null,announcement:typeof e.announcement=="string"?e.announcement:"",config:e.config&&typeof e.config=="object"?{...e.config}:{},workDir:typeof e.workDir=="string"?e.workDir:"",createdAt:e.createdAt||null,updatedAt:e.updatedAt||null,lastMessageAt:e.lastMessageAt||null,running:fu(e),active:fu(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:zr(e,s),sortOrder:Number.isFinite(e.sortOrder)?e.sortOrder:null}}}})});function Kr(){try{if(window.Pinia&&typeof window.Pinia.useAuthStore=="function")return window.Pinia.useAuthStore()}catch{}return null}function fa(){try{return localStorage.getItem("authToken")||null}catch{return null}}function Su(){let e=Kr();if(e)try{return e.getActiveToken?.()||e.token||fa()}catch{return e.token||fa()}return fa()}function Jh(e,t){if(!e)return!1;let s=Su();if(s&&s!==t)return!1;try{localStorage.setItem("authToken",e)}catch{}let n=Kr();return n&&(n.token=e),!0}function ev(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 ku(e){return!e||typeof window>"u"||!window.location?!1:e.origin===window.location.origin&&e.pathname.startsWith("/api/")}function tv(e){if(!e)return!1;let t=e.pathname;return!!(Zh.has(t)||t.startsWith("/api/auth/sso/poll/")||/^\/api\/auth\/sso\/[^/]+\/start(?:-qr)?$/.test(t))}function sv(e,t){return t?.headers?new Headers(t.headers):e&&typeof e=="object"&&e.headers?new Headers(e.headers):new Headers}function nv(e){let t=e.get("Authorization");return!t||!t.startsWith("Bearer ")?null:t.slice(7)}function rv(e,t){return{...e||{},headers:t}}function iv(e,t,s,n){let r=Kr();r&&typeof r.handleAuthResponse=="function"?r.handleAuthResponse(e,t,s,n):r&&typeof r.handleAuthFailure=="function"&&n&&r.handleAuthFailure(void 0,t,s)}function Iu(){if(wu||typeof window>"u"||!window.fetch)return;wu=!0;let e=window.fetch.bind(window);window.fetch=async function(s,n){let r=ev(s),i=ku(r)&&!tv(r),o=ku(r)?{...n||{},credentials:"same-origin"}:n,a=null,l=i?Kr():null,c=l?.authGeneration,d=!!l?.isAuthenticated;if(i){let f=sv(s,n);a=nv(f),a||(a=Su(),a&&(f.set("Authorization",`Bearer ${a}`),o=rv(o,f)))}let u=await e(s,o);try{let f=u.headers&&u.headers.get&&u.headers.get("X-New-Token");f&&Jh(f,a),i&&u.status===401&&iv(u,a,c,d)}catch{}return u}}var wu,Zh,Cu=F(()=>{wu=!1,Zh=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 Au,xu=F(()=>{Au={"common.loading":"\u52A0\u8F7D\u4E2D...","common.confirm":"\u786E\u5B9A","common.apply":"\u5E94\u7528","common.cancel":"\u53D6\u6D88","common.delete":"\u5220\u9664","common.copy":"\u590D\u5236","common.copied":"\u5DF2\u590D\u5236","common.close":"\u5173\u95ED","common.refresh":"\u5237\u65B0","common.open":"\u6253\u5F00","common.save":"\u4FDD\u5B58","common.search":"\u641C\u7D22","common.back":"\u8FD4\u56DE","common.noSubdirectories":"\u65E0\u5B50\u76EE\u5F55","common.drives":"\u9A71\u52A8\u5668","common.rootDir":"\u6839\u76EE\u5F55","common.comma":"\uFF0C","common.select":"\u9009\u62E9","mermaid.export":"\u5BFC\u51FA","mermaid.exportMd":"\u5BFC\u51FA MD","mermaid.exportPng":"\u5BFC\u51FA PNG","mermaid.exportJpg":"\u5BFC\u51FA JPG","chat.toolActionsOmitted":"\u5DF2\u7701\u7565 {count} \u4E2A\u5386\u53F2\u5DE5\u5177\u52A8\u4F5C","login.subtitle":"Yeaft Web Code Agent","login.username":"\u7528\u6237\u540D","login.password":"\u5BC6\u7801","login.login":"\u767B\u5F55","login.loggingIn":"\u767B\u5F55\u4E2D...","login.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.noAccount":"\u6CA1\u6709\u8D26\u53F7\uFF1F","login.registerWithCode":"\u6CE8\u518C\u65B0\u8D26\u53F7","login.or":"\u6216","login.usePassword":"\u4F7F\u7528\u8D26\u53F7\u5BC6\u7801\u767B\u5F55","login.useSso":"\u8FD4\u56DE\u5355\u70B9\u767B\u5F55","login.noProviders":"\u7BA1\u7406\u5458\u5C1A\u672A\u542F\u7528\u4EFB\u4F55\u7B2C\u4E09\u65B9\u767B\u5F55\u3002","login.microsoft":"\u4F7F\u7528 Microsoft \u8D26\u53F7\u767B\u5F55","login.github":"\u4F7F\u7528 GitHub \u8D26\u53F7\u767B\u5F55","login.google":"\u4F7F\u7528 Google \u8D26\u53F7\u767B\u5F55","login.wechat":"\u4F7F\u7528\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.alipay":"\u4F7F\u7528\u652F\u4ED8\u5B9D\u8D26\u53F7\u767B\u5F55","login.wechat.mobileUnsupported":"\u5FAE\u4FE1\u767B\u5F55\u6682\u4EC5\u652F\u6301\u7535\u8111\u7AEF\uFF0C\u8BF7\u5728\u7535\u8111\u6D4F\u89C8\u5668\u4E2D\u626B\u7801\u767B\u5F55\u3002","login.alipay.mobileWaiting":"\u6B63\u5728\u7B49\u5F85\u4F60\u5728\u652F\u4ED8\u5B9D\u4E2D\u786E\u8BA4\u2026 \u5B8C\u6210\u540E\u8FD4\u56DE\u672C\u9875\u9762\u5C06\u81EA\u52A8\u767B\u5F55\u3002","login.alipay.relaunch":"\u91CD\u65B0\u6253\u5F00\u652F\u4ED8\u5B9D","login.qr.title":"\u626B\u7801\u767B\u5F55","login.qr.titleAlipay":"\u652F\u4ED8\u5B9D\u626B\u7801\u767B\u5F55","login.qr.titleWechat":"\u5FAE\u4FE1\u626B\u7801\u767B\u5F55","login.qr.hint":"\u8BF7\u4F7F\u7528\u624B\u673A\u626B\u63CF\u4E8C\u7EF4\u7801\u5B8C\u6210\u6388\u6743","login.error.enterUsername":"\u8BF7\u8F93\u5165\u7528\u6237\u540D","login.error.enterPassword":"\u8BF7\u8F93\u5165\u5BC6\u7801","login.error.enter6Digit":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.error.enterInviteCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.error.usernameMinLen":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.error.passwordMinLen":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.error.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.error.enterVerifyCode":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","login.error.loginFailed":"\u767B\u5F55\u5931\u8D25","login.forgot.link":"\u5FD8\u8BB0\u5BC6\u7801\uFF1F","login.forgot.title":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.emailHint":"\u8F93\u5165\u8D26\u6237\u7ED1\u5B9A\u7684\u90AE\u7BB1\uFF0C\u6211\u4EEC\u5C06\u53D1\u9001 6 \u4F4D\u91CD\u7F6E\u9A8C\u8BC1\u7801\u3002","login.forgot.sendCode":"\u53D1\u9001\u91CD\u7F6E\u9A8C\u8BC1\u7801","login.forgot.sending":"\u53D1\u9001\u4E2D...","login.forgot.codeSent":"\u5982\u679C\u90AE\u7BB1\u5DF2\u6CE8\u518C\uFF0C\u91CD\u7F6E\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u3002\u8BF7\u5728\u4E0B\u65B9\u8F93\u5165\u9A8C\u8BC1\u7801\u4E0E\u65B0\u5BC6\u7801\u3002","login.forgot.resetBtn":"\u91CD\u7F6E\u5BC6\u7801","login.forgot.resetting":"\u91CD\u7F6E\u4E2D...","login.forgot.success":"\u5BC6\u7801\u5DF2\u91CD\u7F6E\uFF0C\u53EF\u4EE5\u4F7F\u7528\u65B0\u5BC6\u7801\u767B\u5F55\u3002","login.forgot.emailInvalid":"\u8BF7\u8F93\u5165\u6709\u6548\u7684\u90AE\u7BB1","login.register.title":"\u65B0\u7528\u6237\u6CE8\u518C","login.register.inviteCode":"\u9080\u8BF7\u7801","login.register.username":"\u7528\u6237\u540D","login.register.password":"\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","login.register.confirmPassword":"\u786E\u8BA4\u5BC6\u7801","login.register.email":"\u90AE\u7BB1\uFF08\u53EF\u9009\uFF09","login.register.submit":"\u6CE8\u518C","login.register.submitting":"\u6CE8\u518C\u4E2D...","login.register.back":"\u8FD4\u56DE\u767B\u5F55","login.register.success":"\u6CE8\u518C\u6210\u529F\uFF0C\u8BF7\u767B\u5F55","login.register.enterCode":"\u8BF7\u8F93\u5165\u9080\u8BF7\u7801","login.register.usernameMin":"\u7528\u6237\u540D\u81F3\u5C112\u4E2A\u5B57\u7B26","login.register.passwordMin":"\u5BC6\u7801\u81F3\u5C116\u4F4D","login.register.passwordMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","login.totp.setupTitle":"\u8BBE\u7F6E\u53CC\u56E0\u7D20\u8BA4\u8BC1","login.totp.setupHint":"\u4F7F\u7528 Microsoft Authenticator \u6216 Google Authenticator \u626B\u63CF\u4E0B\u65B9\u4E8C\u7EF4\u7801","login.totp.manualKey":"\u6216\u624B\u52A8\u8F93\u5165\u5BC6\u94A5\uFF1A","login.totp.enterCode":"\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.totp.complete":"\u5B8C\u6210\u8BBE\u7F6E","login.totp.verifying":"\u9A8C\u8BC1\u4E2D...","login.totp.verify":"\u9A8C\u8BC1","login.totp.prompt":"\u8BF7\u8F93\u5165 Authenticator \u5E94\u7528\u4E2D\u7684\u9A8C\u8BC1\u7801","login.totp.invalidCode":"\u8BF7\u8F93\u51656\u4F4D\u9A8C\u8BC1\u7801","login.email.codeSent":"\u9A8C\u8BC1\u7801\u5DF2\u53D1\u9001\u81F3 {email}","login.email.enterCode":"\u8F93\u5165\u9A8C\u8BC1\u7801","login.email.verify":"\u9A8C\u8BC1","login.email.verifying":"\u9A8C\u8BC1\u4E2D...","login.email.enterCodeError":"\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801","chat.agent.select":"\u9009\u62E9 Agent","chat.agent.manage":"\u7BA1\u7406 Agent","chat.agent.none":"\u6682\u65E0 Agent","chat.agent.restarting":"\u91CD\u542F\u4E2D","chat.agent.restart":"\u91CD\u542F","chat.agent.restartConfirm":`\u786E\u5B9A\u8981\u91CD\u542F Agent "{name}" \u5417\uFF1F
|
|
11
11
|
\u6240\u6709\u6D3B\u8DC3\u7684\u4F1A\u8BDD\u5C06\u88AB\u4E2D\u65AD\u3002`,"chat.agent.upgrade":"\u5347\u7EA7","chat.agent.upgrading":"\u5347\u7EA7\u4E2D","chat.agent.upgradeConfirm":`\u5347\u7EA7 Agent "{name}" \u5230\u6700\u65B0\u7248\u672C\uFF1F
|
|
12
12
|
\u5347\u7EA7\u5B8C\u6210\u540E Agent \u4F1A\u81EA\u52A8\u91CD\u542F\u3002`,"chat.agent.alreadyLatest":"Agent \u5DF2\u662F\u6700\u65B0\u7248\u672C (v{version})\uFF0C\u65E0\u9700\u5347\u7EA7\u3002","chat.agent.nodeIncompatible":"Agent \u5347\u7EA7\u4E2D\u6B62\uFF1A\u76EE\u6807\u7248\u672C v{version} \u9700\u8981 Node {required}\uFF0C\u4F46\u5F53\u524D\u673A\u5668\u8FD0\u884C\u7684\u662F Node {current}\u3002\u8BF7\u5148\u5347\u7EA7 Node.js \u518D\u91CD\u8BD5\u3002","chat.agent.online":"{count} \u4E2A Agent \u5728\u7EBF","chat.agent.selectFirst":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","chat.agent.yeaft":"Yeaft \u5BF9\u8BDD","sidebar.toggle.chat":"\u5207\u6362\u5230 Chat","sidebar.toggle.yeaft":"\u5207\u6362\u5230 Yeaft","sidebar.surface.label":"\u4FA7\u680F\u89C6\u56FE","sidebar.surface.sessions":"\u4F1A\u8BDD","sidebar.provider.label":"\u4F1A\u8BDD Provider","sidebar.provider.claude":"Claude","sidebar.sessions.new":"\u65B0\u5EFA\u4F1A\u8BDD","sidebar.sessions.newChat":"\u65B0\u5EFA\u804A\u5929","sidebar.sessions.emptyProvider":"\u6B64 Provider \u6682\u65E0\u4F1A\u8BDD","sidebar.sessions.menu":"\u4F1A\u8BDD\u83DC\u5355","sidebar.sessions.unread":"\u672A\u8BFB","sidebar.sessions.pinned":"\u5DF2\u7F6E\u9876","sidebar.sessions.processing":"\u6B63\u5728\u56DE\u590D","sidebar.sessions.agent":"Agent","sidebar.sessions.provider":"Provider","sidebar.projects.title":"\u9879\u76EE","sidebar.projects.menu":"\u9879\u76EE\u83DC\u5355","sidebar.projects.new":"\u65B0\u5EFA\u9879\u76EE","sidebar.projects.empty":"\u6682\u65E0\u9879\u76EE","sidebar.projects.noSessions":"\u5C06 Yeaft \u804A\u5929\u62D6\u5230\u8FD9\u91CC","sidebar.projects.namePrompt":"\u9879\u76EE\u540D\u79F0","sidebar.projects.renamePrompt":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.rename":"\u91CD\u547D\u540D\u9879\u76EE","sidebar.projects.delete":"\u5220\u9664\u9879\u76EE","sidebar.projects.deleteConfirm":"\u5220\u9664\u9879\u76EE\u201C{name}\u201D\uFF1F\u5176\u4E2D\u804A\u5929\u4F1A\u79FB\u56DE\u6700\u8FD1\u3002","sidebar.projects.remove":"\u79FB\u51FA\u9879\u76EE","sidebar.projects.moveTo":"\u79FB\u5230 {name}","sidebar.recents.title":"\u6700\u8FD1","sidebar.recents.empty":"\u6682\u65E0\u804A\u5929","yeaft.back":"\u8FD4\u56DE","yeaft.session.people":"\u6210\u5458","yeaft.session.peopleEmpty":"\u6682\u65E0\u6210\u5458","yeaft.session.runningTasks":"\u8FD0\u884C\u4E2D\u7684\u4EFB\u52A1","yeaft.session.tasksEmpty":"\u6682\u65E0\u8FD0\u884C\u4EFB\u52A1","yeaft.session.owner":"\u8D1F\u8D23\u4EBA","yeaft.session.started":"\u5F00\u59CB\u65F6\u95F4","yeaft.breadcrumb.label":"Thread \u8FC7\u6EE4","yeaft.breadcrumb.mainStream":"\u4E3B\u6D41","yeaft.breadcrumb.backHint":"\u8FD4\u56DE\u5168\u6D41 (Esc)","yeaft.featureDetail.ariaLabel":"Task \u8BE6\u60C5","yeaft.featureDetail.replyTo":"\u56DE\u590D\u5230:","yeaft.featureDetail.forkHint":"\u8BE5 task \u6682\u65E0\u6D3B\u8DC3 thread \u2014 \u8BF7 fork \u65B0 thread \u540E\u56DE\u590D\u3002","yeaft.featureDetail.empty":"\u8BE5 task \u6682\u65E0\u6D88\u606F\u3002","yeaft.featureDetail.threadPillHint":"\u6253\u5F00 thread","yeaft.featureDetail.summary.aria":"\u4EFB\u52A1\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.title":"\u6458\u8981\u65F6\u95F4\u7EBF","yeaft.featureDetail.summary.loading":"\u6B63\u5728\u52A0\u8F7D\u6458\u8981\u5386\u53F2\u2026","yeaft.featureDetail.summary.empty":"\u6682\u65E0\u6458\u8981\u3002","yeaft.featureDetail.summary.error":"\u6458\u8981\u52A0\u8F7D\u5931\u8D25\uFF1A{error}","yeaft.featureDetail.summary.showArchived":"\u663E\u793A\u5DF2\u5F52\u6863","yeaft.featureDetail.related.aria":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.title":"\u5173\u8054\u4EFB\u52A1","yeaft.featureDetail.related.unlink":"\u53D6\u6D88\u5173\u8054","yeaft.featureDetail.members.aria":"\u4EFB\u52A1\u6210\u5458","yeaft.featureDetail.members.title":"\u6210\u5458","yeaft.featureDetail.members.abort":"\u4E2D\u6B62","yeaft.featureDetail.members.kick":"\u8E22\u51FA","yeaft.model":"\u6A21\u578B","yeaft.placeholder":"\u95EE\u6211\u4EFB\u4F55\u95EE\u9898...","yeaft.inbox":"\u6536\u4EF6\u7BB1","yeaft.inbox.tooltip":"\u4F60\u7684\u9ED8\u8BA4\u5BF9\u8BDD\u7EBF\u7A0B \u2014\u2014 \u4E0E Yeaft \u7684\u4E00\u5BF9\u4E00\u804A\u5929\u3002\u53EF\u4EE5\u4E3A\u5177\u4F53\u8BDD\u9898\u6216\u4EFB\u52A1\u521B\u5EFA\u65B0\u7EBF\u7A0B\u3002","yeaft.sidebar.activeThreads":"\u6D3B\u8DC3","yeaft.sidebar.idleThreads":"\u9759\u9ED8","yeaft.sidebar.archivedThreads":"\u5DF2\u5F52\u6863","yeaft.sidebar.tasks":"\u4EFB\u52A1","yeaft.sidebar.emptyActive":"\u6682\u65E0\u6D3B\u8DC3 thread","yeaft.sidebar.emptyIdle":"\u6682\u65E0\u9759\u9ED8 thread","yeaft.sidebar.emptyArchived":"\u6682\u65E0\u5F52\u6863 thread","yeaft.sidebar.emptyTasks":"\u65E0\u5339\u914D\u4EFB\u52A1","yeaft.sidebar.results":"\u641C\u7D22\u7ED3\u679C","yeaft.sidebar.resultsThreads":"Threads","yeaft.sidebar.kindThread":"thread","yeaft.sidebar.cancel":"\u53D6\u6D88","yeaft.sidebar.mergeInto":"\u5408\u5E76\u5230\u2026","yeaft.sidebar.mergeNoCandidates":"\u6CA1\u6709\u53EF\u5408\u5E76\u7684\u5176\u4ED6\u7EBF\u7A0B","yeaft.sidebar.mergeConfirmTitle":"\u5408\u5E76\u8FD9\u4E2A\u7EBF\u7A0B\uFF1F","yeaft.sidebar.mergeIrreversible":"\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\uFF0C\u6E90\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\uFF0C\u5176\u6D88\u606F\u4F1A\u88AB\u79FB\u52A8\u5230\u76EE\u6807\u7EBF\u7A0B\u3002","yeaft.sidebar.mergeConfirm":"\u5408\u5E76","yeaft.settings.sidebarV2":"\u5B9E\u9A8C\u529F\u80FD\uFF1A\u4FA7\u8FB9\u680F V2","yeaft.settings.sidebarV2Hint":"Thread \u5217\u8868 + \u4EFB\u52A1\u6811\uFF08\u9884\u89C8\uFF09\u3002","yeaft.clearConfirm":"\u6E05\u7A7A\u6240\u6709\u6D88\u606F\uFF1F","yeaft.mode":"\u6A21\u5F0F","yeaft.agent":"\u667A\u80FD\u4F53","yeaft.connecting":"\u8FDE\u63A5\u4E2D...","yeaft.ready":"\u5C31\u7EEA","yeaft.tools":"\u4E2A\u5DE5\u5177","yeaft.skills":"\u4E2A\u6280\u80FD","yeaft.mcp":"\u4E2A MCP","yeaft.showSidebar":"\u663E\u793A\u4FA7\u680F","yeaft.hideSidebar":"\u9690\u85CF\u4FA7\u680F","yeaft.debug":"\u8C03\u8BD5","yeaft.debugClose":"\u5173\u95ED\u8C03\u8BD5\u9762\u677F","yeaft.debugTurns":"\u8F6E","yeaft.debugTabToolStats":"\u5DE5\u5177\u7EDF\u8BA1","yeaft.debugTabDream":"Dream","yeaft.debugTabRequestLog":"\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugHistoryLoad":"\u52A0\u8F7D\u8BF7\u6C42\u5386\u53F2","yeaft.debugHistoryLoading":"\u52A0\u8F7D\u4E2D...","yeaft.debugHistoryLoaded":"\u5DF2\u52A0\u8F7D {count} \u6761","yeaft.debugSearchPlaceholder":"\u6B63\u5219\u641C\u7D22\u8BF7\u6C42\u65E5\u5FD7","yeaft.debugSearchHint":"\u9ED8\u8BA4\u663E\u793A\u5168\u5C40\u6700\u8FD1 10 \u6761\uFF1B\u641C\u7D22\u4F1A\u8DE8 Session \u5339\u914D\u8BF7\u6C42\u6458\u8981\u3002","yeaft.dreamDebug.title":"Dream \u751F\u547D\u5468\u671F","yeaft.dreamDebug.trigger":"\u89E6\u53D1","yeaft.dreamDebug.status":"\u72B6\u6001","yeaft.dreamDebug.started":"\u5F00\u59CB","yeaft.dreamDebug.finished":"\u7ED3\u675F","yeaft.dreamDebug.time":"\u65F6\u95F4","yeaft.dreamDebug.phase":"\u9636\u6BB5","yeaft.dreamDebug.call":"\u8C03\u7528","yeaft.dreamDebug.location":"\u751F\u6210\u4F4D\u7F6E","yeaft.dreamDebug.result":"\u7ED3\u679C","yeaft.dreamDebug.noLatest":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709\u8BB0\u5F55\u5230 Dream \u68C0\u67E5\u3002","yeaft.dreamDebug.noEvents":"\u8FD9\u4E2A\u4F1A\u8BDD\u8FD8\u6CA1\u6709 Dream \u4E8B\u4EF6\u3002","yeaft.dreamDebug.outputTitle":"\u672C session \u5DF2\u52A0\u8F7D\u7684 Dream \u8F93\u51FA","yeaft.dreamDebug.scope":"Scope","yeaft.dreamDebug.lastDream":"\u4E0A\u6B21 Dream","yeaft.dreamDebug.messagesCovered":"\u5DF2\u8986\u76D6\u6D88\u606F\u6570","yeaft.dreamDebug.noOutput":"\u8FD9\u4E2A session \u8FD8\u6CA1\u6709\u5199\u5165 Dream \u8F93\u51FA\u3002","yeaft.dreamDebug.promptLoadTitle":"\u5DF2\u52A0\u8F7D\u8FDB system prompt \u7684 Dream \u8BB0\u5FC6","yeaft.dreamDebug.loadedInto":"\u52A0\u8F7D\u4F4D\u7F6E","yeaft.dreamDebug.vp":"VP","yeaft.dreamDebug.summaryToPrompt":"summary.md -> system prompt","yeaft.dreamDebug.itemList":"Dream \u8FD0\u884C\u548C Scope","yeaft.dreamDebug.searchPlaceholder":"\u6309\u6807\u9898\u3001ID \u6216\u6458\u8981\u641C\u7D22 Dream Session...","yeaft.dreamDebug.noSearchResults":"\u6CA1\u6709\u5339\u914D\u7684 Dream Session\u3002","yeaft.dreamDebug.noSummary":"\u6682\u65E0\u6458\u8981","yeaft.dreamDebug.segments":"\u6BB5","yeaft.dreamDebug.lastError":"\u6700\u8FD1\u9519\u8BEF","yeaft.dreamDebug.overview":"\u6982\u89C8","yeaft.dreamDebug.sessionId":"Session ID","yeaft.dreamDebug.loadedAt":"\u52A0\u8F7D\u65F6\u95F4","yeaft.dreamDebug.layers":"\u5C42\u7EA7","yeaft.dreamDebug.summaryLayer":"Resident summary","yeaft.dreamDebug.noPromptLoad":"\u8FD9\u4E2A scope \u6682\u65E0 prompt-load \u8BB0\u5F55\u3002","yeaft.dreamDebug.segmentTitle":"Segments","yeaft.dreamDebug.sourceMessages":"\u6765\u6E90\u6D88\u606F","yeaft.dreamDebug.createdAt":"\u521B\u5EFA\u65F6\u95F4","yeaft.dreamDebug.updatedAt":"\u66F4\u65B0\u65F6\u95F4","yeaft.dreamDebug.noSegments":"\u8FD9\u4E2A scope \u6682\u65E0 memory segments\u3002","yeaft.dreamDebug.requestResponse":"Request / Response","yeaft.dreamDebug.noRequestResponse":"\u8FD9\u4E2A scope \u8FD8\u6CA1\u6709\u6301\u4E45\u5316\u7684 Dream request/response \u65E5\u5FD7\u3002","yeaft.dreamDebug.empty":"\u6682\u65E0 Dream debug \u6570\u636E\u3002","yeaft.debugGroupFollowMain":"\u8DDF\u968F\u4E3B\u9762\u677F","yeaft.debugGroupAll":"\u5168\u90E8\u4F1A\u8BDD","yeaft.debugAssistantResponse":"Assistant \u56DE\u590D","yeaft.debugViewAssistantResponse":"\u67E5\u770B\u56DE\u590D","yeaft.debugToolInput":"\u8F93\u5165","yeaft.debugToolResult":"\u7ED3\u679C","yeaft.debugToolRunning":"\u6267\u884C\u4E2D","yeaft.debugToolRunningNoResult":"\u6267\u884C\u4E2D\uFF0C\u6682\u65E0\u7ED3\u679C","yeaft.debugShowDetails":"\u5C55\u5F00","yeaft.debugHideDetails":"\u6536\u8D77","yeaft.debugTurnStartedAt":"\u56DE\u5408\u5F00\u59CB\u65F6\u95F4","yeaft.debugRequestAt":"\u8BF7\u6C42\u65F6\u95F4","yeaft.debugRequestAtDerived":"\u7531\u56DE\u5408\u5F00\u59CB\u65F6\u95F4\u63A8\u7B97\uFF08\u65E7 loop\uFF09","yeaft.turn":"\u7B2C {n} \u8F6E","yeaft.systemPrompt":"\u7CFB\u7EDF\u63D0\u793A","yeaft.messagesLabel":"\u6D88\u606F","yeaft.response":"\u56DE\u590D","yeaft.toolCalls":"\u5DE5\u5177\u8C03\u7528","yeaft.functionCalls":"\u51FD\u6570\u8C03\u7528","yeaft.request":"\u8BF7\u6C42","yeaft.pending":"(\u7B49\u5F85\u4E2D)","yeaft.inputTokens":"\u8F93\u5165","yeaft.outputTokens":"\u8F93\u51FA","yeaft.duration":"\u8017\u65F6","yeaft.noDebugData":"\u6682\u65E0\u8C03\u8BD5\u6570\u636E","yeaft.showDebug":"\u663E\u793A\u8C03\u8BD5\u9762\u677F","yeaft.hideDebug":"\u9690\u85CF\u8C03\u8BD5\u9762\u677F","yeaft.reloadPage":"\u5237\u65B0\u9875\u9762","yeaft.reloadMessages":"\u91CD\u65B0\u52A0\u8F7D\u6D88\u606F","yeaft.historySearch.label":"\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.button":"\u641C\u7D22\u6D88\u606F","yeaft.historySearch.placeholder":"\u641C\u7D22\u5F53\u524D Session \u7684\u6D88\u606F","yeaft.historySearch.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.historySearch.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.historySearch.empty":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.historySearch.error":"\u641C\u7D22\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.historySearch.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u641C\u7D22 Session \u5386\u53F2\u6D88\u606F","yeaft.historySearch.more":"\u52A0\u8F7D\u66F4\u591A\u7ED3\u679C","yeaft.historySearch.you":"\u4F60","yeaft.historySearch.assistant":"\u52A9\u624B","yeaft.outline.label":"\u5386\u53F2\u6D88\u606F","yeaft.outline.sender":"\u53D1\u9001\u8005","yeaft.outline.allSenders":"\u5168\u90E8\u53D1\u9001\u8005","yeaft.outline.title":"\u5386\u53F2\u6D88\u606F","yeaft.outline.placeholder":"\u641C\u7D22\u5F53\u524D\u5BF9\u8BDD","yeaft.outline.searching":"\u6B63\u5728\u641C\u7D22\u2026","yeaft.outline.loading":"\u6B63\u5728\u52A0\u8F7D\u2026","yeaft.outline.older":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","yeaft.outline.moreMatches":"\u52A0\u8F7D\u66F4\u591A\u5339\u914D\u9879","yeaft.outline.minChars":"\u81F3\u5C11\u8F93\u5165 2 \u4E2A\u5B57\u7B26","yeaft.outline.empty":"\u6682\u65E0\u6D88\u606F","yeaft.outline.noMatches":"\u6CA1\u6709\u5339\u914D\u7684\u6D88\u606F","yeaft.outline.error":"\u5927\u7EB2\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5","yeaft.outline.unsupported":"\u8BF7\u5347\u7EA7\u5F53\u524D Agent \u540E\u518D\u4F7F\u7528\u5BF9\u8BDD\u5927\u7EB2","yeaft.outline.you":"\u4F60","yeaft.outline.assistant":"\u52A9\u624B","yeaft.outline.nonText":"\u975E\u6587\u672C\u56DE\u590D","yeaft.switchModel":"\u5207\u6362\u6A21\u578B","yeaft.modelMenu.title":"\u6A21\u578B\u548C LLM \u8BBE\u7F6E","yeaft.modelMenu.label":"\u6A21\u578B","yeaft.modelMenu.effort":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.openaiReasoning":"\u63A8\u7406\u5F3A\u5EA6","yeaft.modelMenu.effort.anthropicBudget":"\u601D\u8003\u9884\u7B97","yeaft.modelMenu.effort.anthropicAdaptive":"\u81EA\u9002\u5E94\u601D\u8003\u5F3A\u5EA6","yeaft.modelMenu.effort.minimal":"\u6700\u5C0F","yeaft.modelMenu.effort.low":"\u4F4E","yeaft.modelMenu.effort.medium":"\u4E2D","yeaft.modelMenu.effort.high":"\u9AD8","yeaft.modelMenu.effort.xhigh":"\u8D85\u9AD8","yeaft.modelMenu.effort.max":"\u6700\u9AD8","yeaft.modelMenu.noEffort":"\u5F53\u524D\u6A21\u578B\u6CA1\u6709\u53EF\u517C\u5BB9\u6620\u5C04\u7684\u63A8\u7406\u5F3A\u5EA6\u63A7\u5236\u3002","yeaft.modelMenu.configureHint":"Provider\u3001\u5BC6\u94A5\u3001\u6A21\u578B\u5217\u8868","yeaft.settings.title":"\u8BBE\u7F6E","yeaft.settings.tabs.vp":"VP \u5E93","yeaft.settings.tabs.search":"\u641C\u7D22","search.settings.backendTitle":"\u641C\u7D22\u540E\u7AEF","search.settings.backendDesc":"\u9009\u62E9 WebSearch \u5DE5\u5177\u9ED8\u8BA4\u4F7F\u7528\u7684\u540E\u7AEF\u3002\u4E3B\u540E\u7AEF\u5931\u8D25\u65F6,\u5F15\u64CE\u4F1A\u81EA\u52A8\u964D\u7EA7\u5230 HTML \u6293\u53D6\u3002","search.settings.backend.tavily":"Tavily","search.settings.backend.tavilyHint":"\u6258\u7BA1\u641C\u7D22 API\u3002\u514D\u8D39\u989D\u5EA6 1000 \u6B21/\u6708\u3002\u63A8\u8350\u3002","search.settings.backend.playwright":"Playwright \u670D\u52A1","search.settings.backend.playwrightHint":"\u81EA\u5EFA\u7684\u6D4F\u89C8\u5668\u5F0F\u641C\u7D22/\u6293\u53D6\u670D\u52A1,\u9002\u5408 IP \u4FE1\u8A89\u5DEE\u88AB bot \u68C0\u6D4B\u7684\u73AF\u5883\u3002\u5C1A\u672A\u4E0A\u7EBF\u3002","search.settings.comingSoon":"\u5373\u5C06\u63A8\u51FA","search.settings.tavilyKeyTitle":"Tavily API key","search.settings.tavilyKeyDesc":"\u4FDD\u5B58\u5728 agent \u7684 ~/.yeaft/config.json \u4E2D\u3002\u514D\u8D39\u7533\u8BF7:","search.settings.tavilyKeyUnchanged":"\u4FDD\u6301\u4E0D\u53D8","search.settings.clearKey":"\u6E05\u9664","search.settings.usageTitle":"\u672C\u6708\u7528\u91CF","search.settings.usageRefresh":"\u5237\u65B0","search.settings.usageLoading":"\u52A0\u8F7D\u4E2D\u2026","search.settings.usagePlan":"\u8BA1\u5212","search.settings.usageUsed":"\u5DF2\u7528","search.settings.usagePaygo":"\u6309\u91CF\u4ED8\u8D39","search.settings.usageError":"\u52A0\u8F7D\u7528\u91CF\u5931\u8D25","search.settings.save":"\u4FDD\u5B58","search.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","search.settings.saveSuccess":"\u5DF2\u4FDD\u5B58","search.settings.cancel":"\u91CD\u7F6E","yeaft.settings.yeaftTitle":"\u7EBF\u7A0B\u5E76\u53D1\u4E0E\u5F52\u6863","yeaft.settings.yeaftDesc":"\u8C03\u6574\u53EF\u540C\u65F6\u8FD0\u884C\u7684\u7EBF\u7A0B\u6570\u91CF\uFF0C\u4EE5\u53CA\u95F2\u7F6E\u7EBF\u7A0B\u7684\u81EA\u52A8\u5F52\u6863\u65F6\u957F\u3002","yeaft.settings.maxConcurrentLabel":"\u6700\u5927\u5E76\u53D1\u7EBF\u7A0B\u6570","yeaft.settings.maxConcurrentHint":"\u540C\u65F6\u5728\u7EBF\u7684\u7EBF\u7A0B\u603B\u6570\u4E0A\u9650\uFF08\u542B\u59CB\u7EC8\u5B58\u5728\u7684 main \u4E3B\u7EBF\u7A0B\uFF09\u3002\u8D85\u8FC7\u6B64\u4E0A\u9650\u7684\u65B0\u7EBF\u7A0B\u5C06\u88AB\u62D2\u7EDD\uFF0C\u76F4\u81F3\u5DF2\u6709\u7EBF\u7A0B\u88AB\u5F52\u6863\u6216\u7EC8\u6B62\u3002\u8303\u56F4\uFF1A1-50\u3002","yeaft.settings.archiveIdleDaysLabel":"\u95F2\u7F6E\u591A\u4E45\u540E\u81EA\u52A8\u5F52\u6863\u7EBF\u7A0B\uFF08\u5929\uFF09","yeaft.settings.archiveIdleDaysHint":"\u65E0\u6D3B\u52A8\u8D85\u8FC7\u6B64\u5929\u6570\u7684\u7EBF\u7A0B\u5C06\u88AB\u5F52\u6863\u3002\u8303\u56F4\uFF1A1-3650\u3002","yeaft.settings.yeaftSaveBtn":"\u4FDD\u5B58","yeaft.settings.yeaftSaving":"\u4FDD\u5B58\u4E2D...","yeaft.settings.yeaftSaved":"\u5DF2\u4FDD\u5B58","yeaft.settings.yeaftLoading":"\u52A0\u8F7D\u4E2D...","yeaft.settings.yeaftLoadError":"\u52A0\u8F7D Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.yeaftSaveError":"\u4FDD\u5B58 Yeaft \u8BBE\u7F6E\u5931\u8D25","yeaft.settings.rangeErrorConcurrent":"\u5FC5\u987B\u5728 1 \u5230 50 \u4E4B\u95F4","yeaft.settings.rangeErrorArchive":"\u5FC5\u987B\u5728 1 \u5230 3650 \u4E4B\u95F4","chat.session.creating":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","chat.session.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","yeaft.historyLoad.error":"\u4F1A\u8BDD\u5386\u53F2\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D\uFF0C\u6D88\u606F\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.historyLoad.retry":"\u91CD\u65B0\u52A0\u8F7D","yeaft.sessionInventory.error":"\u6682\u65F6\u65E0\u6CD5\u52A0\u8F7D Session\uFF0C\u4F1A\u8BDD\u4ECD\u5B89\u5168\u4FDD\u5B58\u5728 Agent \u4E2D\u3002","yeaft.sessionInventory.retry":"\u91CD\u65B0\u52A0\u8F7D Session","chat.session.closed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","chat.session.agentOffline":"Agent \u5DF2\u79BB\u7EBF\uFF0C\u8BE5\u4F1A\u8BDD\u5C06\u5728 Agent \u91CD\u65B0\u4E0A\u7EBF\u540E\u6062\u590D\u3002","chat.execution.cancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","chat.sidebar.expand":"\u5C55\u5F00\u83DC\u5355","chat.sidebar.collapse":"\u6536\u8D77\u4FA7\u8FB9\u680F","chat.sidebar.workbench":"\u5DE5\u5177\u9762\u677F","chat.sidebar.newConv":"\u4F1A\u8BDD","chat.sidebar.recentChats":"\u6700\u8FD1\u4F1A\u8BDD","chat.sidebar.resumeConv":"\u6062\u590D\u4F1A\u8BDD","chat.sidebar.lightMode":"\u6D45\u8272\u6A21\u5F0F","chat.sidebar.darkMode":"\u6DF1\u8272\u6A21\u5F0F","chat.sidebar.settings":"\u8BBE\u7F6E","chat.sidebar.emptyHint":"\u70B9\u51FB\u4E0A\u65B9\u6309\u94AE\u521B\u5EFA\u65B0\u4F1A\u8BDD","chat.sidebar.closeConv":"\u5173\u95ED\u4F1A\u8BDD","chat.sidebar.renameConv":"\u91CD\u547D\u540D","chat.sidebar.pin":"\u7F6E\u9876","chat.sidebar.unpin":"\u53D6\u6D88\u7F6E\u9876","chat.connection.connecting":"\u8FDE\u63A5\u4E2D...","chat.connection.reconnecting":"\u91CD\u8FDE\u4E2D ({current}/{max})...","chat.connection.updating":"\u670D\u52A1\u6B63\u5728\u66F4\u65B0\uFF0C\u8BF7\u7A0D\u5019...","chat.connection.disconnected":"\u8FDE\u63A5\u65AD\u5F00","chat.connection.reconnect":"\u91CD\u8FDE","chat.connection.reconnectFailed":"\u8FDE\u63A5\u65AD\u5F00\uFF0C\u8BF7\u70B9\u51FB\u91CD\u8FDE\u6309\u94AE\u91CD\u8BD5\u3002","chat.time.justNow":"\u521A\u521A","chat.time.minutesAgo":"{count}\u5206\u949F\u524D","chat.time.daysAgo":"{count}\u5929\u524D","chat.time.today":"\u4ECA\u5929","chat.time.yesterday":"\u6628\u5929","chat.delete.confirm":"\u786E\u5B9A\u8981\u5173\u95ED\u8FD9\u4E2A\u4F1A\u8BDD\u5417\uFF1F\u8FD9\u5C06\u7EC8\u6B62\u5BF9\u5E94\u7684 Claude \u8FDB\u7A0B\u3002","chat.delete.enterWorkDir":"\u8BF7\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u8DEF\u5F84","modal.newConv.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.newConv.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.newConv.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.newConv.create":"\u521B\u5EFA\u4F1A\u8BDD","modal.newConv.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.newConv.provider":"\u63D0\u4F9B\u65B9","modal.newConv.model":"\u6A21\u578B","provider.claudeCode":"Claude Code","provider.copilot":"Copilot","modal.resume.workDir":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.inputOrSelect":"\u8F93\u5165\u6216\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.browse":"\u6D4F\u89C8\u76EE\u5F55","modal.resume.tabFolders":"\u5DE5\u4F5C\u76EE\u5F55","modal.resume.tabSessions":"\u5386\u53F2\u4F1A\u8BDD","modal.resume.noWorkDirs":"\u6682\u65E0\u5DE5\u4F5C\u76EE\u5F55","modal.resume.selectWorkDir":"\u8BF7\u5148\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.resume.noSessions":"\u8BE5\u76EE\u5F55\u4E0B\u6CA1\u6709\u5386\u53F2\u4F1A\u8BDD","modal.resume.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","modal.resume.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","modal.resume.sessionLabel":"\u{1F4AC} \u5386\u53F2\u4F1A\u8BDD","modal.resume.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A\u5728\u7EBF\u7684 Agent","modal.folderPicker.title":"\u9009\u62E9\u5DE5\u4F5C\u76EE\u5F55","modal.folderPicker.parentDir":"\u4E0A\u7EA7\u76EE\u5F55","welcome.subtitle":"\u9762\u5411 Session\u3001\u5DE5\u5177\u548C VP \u534F\u4F5C\u7684 Web Code Agent","welcome.agentOnline":"{count} \u4E2A Agent \u5728\u7EBF","welcome.noAgents":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentsHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.noAgent":"\u6682\u65E0\u5728\u7EBF Agent","welcome.noAgentHint":"\u8BF7\u5148\u542F\u52A8 Agent \u7A0B\u5E8F\u8FDE\u63A5\u5230\u670D\u52A1\u5668","welcome.setupAgent":"\u8BBE\u7F6E Agent","welcome.setupKicker":"Agent \u63A5\u5165","welcome.setupTitle":"\u8FDE\u63A5\u4F60\u7684\u7B2C\u4E00\u4E2A Yeaft Agent","welcome.setupDesc":"\u590D\u5236\u4E24\u6761\u547D\u4EE4\u5373\u53EF\u8FDE\u63A5\u672C\u673A Agent\u3002\u6A21\u578B\u53EF\u7528 GitHub Copilot \u81EA\u52A8\u914D\u7F6E\u3002","welcome.setupInstallTitle":"\u5B89\u88C5 CLI","welcome.setupCopilotTitle":"\u914D\u7F6E\u6A21\u578B","welcome.setupRunTitle":"\u542F\u52A8 Agent","welcome.setupSecretLoading":"\u6B63\u5728\u51C6\u5907 Agent secret...","welcome.setupSecretError":"\u65E0\u6CD5\u51C6\u5907 Agent secret\uFF0C\u8BF7\u6253\u5F00\u5B89\u5168\u8BBE\u7F6E\u91CD\u8BD5\u3002","welcome.openSecuritySettings":"\u6253\u5F00\u5B89\u5168\u8BBE\u7F6E","welcome.newConv":"\u4F1A\u8BDD","welcome.resumeHistory":"\u6062\u590D\u5386\u53F2","messages.loadingMore":"\u52A0\u8F7D\u66F4\u591A\u6D88\u606F...","messages.loadMore":"\u2191 \u70B9\u51FB\u6216\u5411\u4E0A\u6EDA\u52A8\u52A0\u8F7D\u66F4\u591A","message.loadingMore":"\u52A0\u8F7D\u66F4\u591A\u6D88\u606F...","message.loadMore":"\u2191 \u70B9\u51FB\u6216\u5411\u4E0A\u6EDA\u52A8\u52A0\u8F7D\u66F4\u591A","message.scrollToLatest":"\u2193 \u6700\u65B0","message.showResponses":"\u5C55\u5F00 {count} \u6761\u56DE\u590D","message.hideResponses":"\u6298\u53E0\u56DE\u590D","message.assistant":"\u52A9\u624B","chat.waiting.disconnected":"\u8FDE\u63A5\u5DF2\u65AD\u5F00","chat.connecting":"\u6B63\u5728\u8FDE\u63A5 provider \u4F1A\u8BDD...","chat.waiting.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","chat.waiting.agentOffline":"Agent \u5DF2\u79BB\u7EBF","chat.waiting.sessionLost":"Session \u5DF2\u4E22\u5931\uFF0C\u5DF2\u5237\u65B0\uFF0C\u7B49\u5F85\u6700\u65B0\u4FE1\u606F...","chat.waiting.cliExited":"Claude \u8FDB\u7A0B\u5DF2\u9000\u51FA\uFF0C\u5DF2\u5237\u65B0\uFF0C\u7B49\u5F85\u6700\u65B0\u4FE1\u606F...","chat.waiting.refresh":"\u5237\u65B0","chat.waiting.thinking":"AI \u6B63\u5728\u601D\u8003\u4E2D\uFF0C\u8BF7\u7A0D\u5019...","btw.hint":"esc \u9000\u51FA","btw.placeholder":"\u95EE\u4E2A\u987A\u4FBF\u7684\u95EE\u9898...","btw.close":"\u9000\u51FA BTW \u6A21\u5F0F","message.copyContent":"\u590D\u5236\u5185\u5BB9","message.copy":"\u590D\u5236\u5185\u5BB9","message.copied":"\u5DF2\u590D\u5236","message.copyCode":"\u590D\u5236\u4EE3\u7801","message.copyAll":"\u590D\u5236\u5168\u90E8","message.screenshot":"\u622A\u56FE","message.screenshotting":"\u6B63\u5728\u622A\u56FE...","message.exportMd":"\u5BFC\u51FA MD","message.askInput":"\u9700\u8981\u4F60\u7684\u8F93\u5165","message.askAnswered":"\u2713 \u5DF2\u56DE\u7B54","message.askCustom":"\u6216\u8F93\u5165\u81EA\u5B9A\u4E49\u56DE\u7B54...","message.askCustomPlaceholder":"\u6216\u8F93\u5165\u81EA\u5B9A\u4E49\u56DE\u7B54...","message.askSubmit":"\u63D0\u4EA4\u56DE\u7B54","message.askWaiting":"\u7B49\u5F85\u95EE\u9898\u52A0\u8F7D...","message.askExpired":"\u6B64\u95EE\u9898\u5DF2\u5931\u6548\uFF0C\u8BF7\u8BA9\u89D2\u8272\u91CD\u65B0\u63D0\u95EE","message.openInEditor":"\u5728\u7F16\u8F91\u5668\u4E2D\u6253\u5F00","message.resultDone":"\u5B8C\u6210","message.done":"\u5B8C\u6210","message.resultRead":"\u8BFB\u53D6 {file}","message.readFile":"\u8BFB\u53D6 {name}","message.file":"\u6587\u4EF6","message.attachImages":"{count} \u5F20\u56FE\u7247","message.imageCount":"{count} \u5F20\u56FE\u7247","message.imagePreview":"\u56FE\u7247\u9884\u89C8","message.imageUnavailable":"\u56FE\u7247\u65E0\u6CD5\u52A0\u8F7D","message.attachFiles":"{count} \u4E2A\u6587\u4EF6","message.fileCount":"{count} \u4E2A\u6587\u4EF6","message.quote":"\u5F15\u7528","message.removeQuote":"\u5220\u9664\u5F15\u7528","message.replyingTo":"\u6B63\u5728\u56DE\u590D {author}","message.quotedFrom":"\u5F15\u7528\u81EA {author}","message.editAsNew":"\u7F16\u8F91","message.you":"\u4F60","input.upload":"\u4E0A\u4F20\u6587\u4EF6","input.placeholder":"\u8F93\u5165\u6D88\u606F...","input.send":"\u53D1\u9001","input.stopExecution":"\u505C\u6B62\u6267\u884C","chatInput.upload":"\u4E0A\u4F20\u6587\u4EF6","chatInput.uploading":"\u6B63\u5728\u4E0A\u4F20\u2026","chatInput.uploadFailed":"\u4E0A\u4F20\u5931\u8D25","chatInput.retryUpload":"\u91CD\u8BD5","chatInput.removeAttachment":"\u79FB\u9664\u9644\u4EF6","chatInput.placeholder":"\u8F93\u5165\u6D88\u606F...","chatInput.send":"\u53D1\u9001","chatInput.stop":"\u505C\u6B62\u6267\u884C","tools.thinking":"\u601D\u8003\u4E2D...","tools.read":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","tools.write":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","tools.edit":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","tools.bash":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","tools.glob":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","tools.grep":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","tools.task":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","tools.webFetch":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","tools.webSearch":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","tools.todoWrite":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","tools.executing":"\u6B63\u5728\u6267\u884C {name}","status.thinking":"\u601D\u8003\u4E2D...","status.reading":"\u6B63\u5728\u8BFB\u53D6\u6587\u4EF6","status.writing":"\u6B63\u5728\u5199\u5165\u6587\u4EF6","status.editing":"\u6B63\u5728\u7F16\u8F91\u6587\u4EF6","status.executing":"\u6B63\u5728\u6267\u884C\u547D\u4EE4","status.searchingFiles":"\u6B63\u5728\u641C\u7D22\u6587\u4EF6","status.searchingContent":"\u6B63\u5728\u641C\u7D22\u5185\u5BB9","status.executingTask":"\u6B63\u5728\u6267\u884C\u4EFB\u52A1","status.fetching":"\u6B63\u5728\u83B7\u53D6\u7F51\u9875","status.searching":"\u6B63\u5728\u641C\u7D22\u7F51\u7EDC","status.updatingTasks":"\u6B63\u5728\u66F4\u65B0\u4EFB\u52A1","status.executingTool":"\u6B63\u5728\u6267\u884C {name}","header.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","header.compacted":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.newConv":"\u4F1A\u8BDD","chatHeader.compacting":"\u6B63\u5728\u538B\u7F29\u4E0A\u4E0B\u6587...","chatHeader.compactDone":"\u4E0A\u4E0B\u6587\u538B\u7F29\u5B8C\u6210","chatHeader.compact":"\u538B\u7F29\u4E0A\u4E0B\u6587","chatHeader.resume":"\u6062\u590D\u4F1A\u8BDD","chatHeader.refresh":"\u5237\u65B0\u6D88\u606F","chatHeader.reloadPage":"\u5237\u65B0\u9875\u9762","chatHeader.clear":"\u6E05\u7A7A\u6D88\u606F","chatHeader.clearing":"\u6B63\u5728\u6E05\u7A7A\u4E0A\u4E0B\u6587...","chatHeader.clearDone":"\u4E0A\u4E0B\u6587\u5DF2\u6E05\u7A7A","chatHeader.confirmClear":"\u786E\u5B9A\u8981\u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u7684\u6240\u6709\u6D88\u606F\u5417\uFF1F","chatHeader.mcpConfig":"MCP \u670D\u52A1\u5668\u914D\u7F6E","chatHeader.mcpNeedRestart":"\u66F4\u6539\u5C06\u5728\u91CD\u542F\u4F1A\u8BDD\u540E\u751F\u6548\u3002","chatHeader.expertPanel":"\u5E2E\u5E2E\u56E2","chatHeader.subAgentPanel":"\u5B50\u4EE3\u7406","settings.close":"\u5173\u95ED\u8BBE\u7F6E","settings.tabs.account":"\u8D26\u53F7","settings.tabs.security":"\u5B89\u5168","settings.tabs.general":"\u901A\u7528","settings.tabs.invitations":"\u9080\u8BF7","auth.sessionExpired":"\u767B\u5F55\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002","settings.account.username":"\u7528\u6237\u540D","settings.account.role":"\u89D2\u8272","settings.account.email":"\u90AE\u7BB1","settings.account.emailNotSet":"\u672A\u8BBE\u7F6E","settings.account.profileLoadFailed":"\u8D26\u53F7\u8D44\u6599\u52A0\u8F7D\u5931\u8D25","settings.account.logout":"\u9000\u51FA\u767B\u5F55","settings.account.roleAdmin":"\u7BA1\u7406\u5458","settings.account.rolePro":"Pro","settings.account.linkedAccounts":"\u5DF2\u5173\u8054\u8D26\u6237","settings.account.linkedDesc":"\u5173\u8054\u7B2C\u4E09\u65B9\u767B\u5F55\u540E\uFF0C\u4F7F\u7528\u4EFB\u610F\u4E00\u79CD\u65B9\u5F0F\u90FD\u80FD\u767B\u5F55\u6B64\u8D26\u53F7\u3002","settings.account.bind":"\u7ED1\u5B9A","settings.account.unbind":"\u89E3\u7ED1","settings.account.linked":"\u5DF2\u7ED1\u5B9A","settings.account.providerDisabled":"\u672A\u914D\u7F6E","settings.account.cantUnbindLast":"\u4E0D\u80FD\u89E3\u7ED1\u552F\u4E00\u7684\u767B\u5F55\u65B9\u5F0F","settings.account.unbindFailed":"\u89E3\u7ED1\u5931\u8D25\uFF1A{error}","settings.account.bindFailed":"\u7ED1\u5B9A\u5931\u8D25","settings.account.ssoBoundMsg":"\u5DF2\u6210\u529F\u7ED1\u5B9A {provider}\u3002","settings.account.ssoConflictMsg":"\u8BE5 {provider} \u8D26\u53F7\u5DF2\u88AB\u5176\u4ED6\u7528\u6237\u7ED1\u5B9A\u3002","settings.account.providerMicrosoft":"Microsoft","settings.account.providerGithub":"GitHub","settings.account.providerGoogle":"Google","settings.account.providerWechat":"\u5FAE\u4FE1","settings.account.providerAlipay":"\u652F\u4ED8\u5B9D","settings.security.agentKey":"Agent \u5BC6\u94A5","settings.security.agentKeyDesc":"\u7528\u4E8E Agent \u8FDE\u63A5\u8BA4\u8BC1\u7684\u5171\u4EAB\u5BC6\u94A5","settings.security.agentSetupCommands":"Agent \u63A5\u5165\u547D\u4EE4","settings.security.agentCmdInstall":"\u5B89\u88C5 Agent","settings.security.agentCmdService":"\u8FD0\u884C Agent server","settings.security.agentCmdNeedsSecret":"\u8BF7\u5148\u751F\u6210 Agent \u5BC6\u94A5\uFF0C\u4EE5\u521B\u5EFA\u5305\u542B server \u5730\u5740\u548C\u5BC6\u94A5\u7684\u547D\u4EE4\u3002","settings.security.agentCmdLlm":"Copilot \u624B\u52A8\u515C\u5E95","settings.security.agentCmdLlmDesc":"\u5148\u8FD0\u884C\u5B89\u88C5\u547D\u4EE4\uFF1B\u5982\u679C\u672C\u673A\u5DF2\u6709 GitHub Copilot token\uFF0CYeaft \u4F1A\u81EA\u52A8\u914D\u7F6E github-copilot/gpt-5.5\u3002Copilot \u547D\u4EE4\u53EA\u4F5C\u4E3A\u515C\u5E95\u4F7F\u7528\u3002","settings.security.none":"\u65E0","settings.security.show":"\u663E\u793A","settings.security.hide":"\u9690\u85CF","settings.security.generateKey":"\u751F\u6210\u5BC6\u94A5","settings.security.resetKey":"\u91CD\u7F6E\u5BC6\u94A5","settings.security.resetting":"\u91CD\u7F6E\u4E2D...","settings.security.resetWarning":"\u91CD\u7F6E\u540E\u6240\u6709 Agent \u9700\u91CD\u65B0\u914D\u7F6E","settings.security.changePassword":"\u4FEE\u6539\u5BC6\u7801","settings.security.currentPassword":"\u5F53\u524D\u5BC6\u7801","settings.security.newPassword":"\u65B0\u5BC6\u7801\uFF08\u81F3\u5C116\u4F4D\uFF09","settings.security.confirmPassword":"\u786E\u8BA4\u65B0\u5BC6\u7801","settings.security.changeBtn":"\u4FEE\u6539\u5BC6\u7801","settings.security.changing":"\u4FEE\u6539\u4E2D...","settings.security.enterCurrentPwd":"\u8BF7\u8F93\u5165\u5F53\u524D\u5BC6\u7801","settings.security.newPwdMin":"\u65B0\u5BC6\u7801\u81F3\u5C116\u4F4D","settings.security.pwdMismatch":"\u4E24\u6B21\u5BC6\u7801\u4E0D\u4E00\u81F4","settings.security.pwdChanged":"\u5BC6\u7801\u4FEE\u6539\u6210\u529F","settings.security.setPassword":"\u8BBE\u7F6E\u5BC6\u7801","settings.security.setPasswordDesc":"\u4F60\u76EE\u524D\u901A\u8FC7 SSO \u767B\u5F55\uFF0C\u5C1A\u672A\u8BBE\u7F6E\u5BC6\u7801\u3002\u8BBE\u7F6E\u540E\u5373\u53EF\u4F7F\u7528\u7528\u6237\u540D + \u5BC6\u7801\u767B\u5F55\u3002","settings.security.setBtn":"\u8BBE\u7F6E\u5BC6\u7801","settings.security.pwdSet":"\u5BC6\u7801\u8BBE\u7F6E\u6210\u529F","settings.security.deleteAccount":"\u6CE8\u9500\u8D26\u6237","settings.security.deleteAccountDesc":"\u6C38\u4E45\u5220\u9664\u4F60\u7684\u8D26\u6237\u548C\u6240\u6709\u76F8\u5173\u6570\u636E\u3002\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002","settings.security.deleteBtn":"\u6CE8\u9500\u8D26\u6237","settings.security.deleteConfirmBtn":"\u786E\u8BA4\u5220\u9664","settings.security.deleteConfirmPlaceholder":"\u8F93\u5165 DELETE \u4EE5\u786E\u8BA4","settings.security.deleteConfirmRequired":"\u8BF7\u8F93\u5165 DELETE \u4EE5\u786E\u8BA4\u6CE8\u9500\u8D26\u6237","settings.security.deleteFailed":"\u6CE8\u9500\u8D26\u6237\u5931\u8D25","settings.security.deleting":"\u6CE8\u9500\u4E2D...","settings.general.theme":"\u4E3B\u9898","settings.general.lightTheme":"\u6D45\u8272","settings.general.darkTheme":"\u6DF1\u8272","settings.general.language":"\u8BED\u8A00","settings.invite.create":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.normalUser":"\u666E\u901A\u7528\u6237","settings.invite.proUser":"Pro \u7528\u6237","settings.invite.createBtn":"\u521B\u5EFA\u9080\u8BF7\u7801","settings.invite.creating":"\u521B\u5EFA\u4E2D...","settings.invite.list":"\u9080\u8BF7\u7801\u5217\u8868","settings.invite.used":"\u5DF2\u4F7F\u7528","settings.invite.expired":"\u5DF2\u8FC7\u671F","settings.invite.available":"\u53EF\u7528","settings.invite.usedBy":"\u4F7F\u7528\u8005: {user}","settings.invite.expiredAt":"\u8FC7\u671F\u4E8E: {time}","settings.invite.expiresAt":"\u6709\u6548\u81F3: {time}","settings.invite.noInvites":"\u6682\u65E0\u9080\u8BF7\u7801","settings.msg.copiedClipboard":"\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F","settings.msg.copyFailed":"\u590D\u5236\u5931\u8D25","settings.msg.keyReset":"\u5BC6\u94A5\u5DF2\u91CD\u7F6E","settings.msg.resetFailed":"\u91CD\u7F6E\u5931\u8D25","settings.msg.changeFailed":"\u4FEE\u6539\u5931\u8D25","settings.msg.inviteCreated":"\u9080\u8BF7\u7801\u5DF2\u521B\u5EFA","settings.msg.createFailed":"\u521B\u5EFA\u5931\u8D25","settings.msg.inviteCopied":"\u9080\u8BF7\u7801\u5DF2\u590D\u5236","settings.msg.inviteDeleted":"\u9080\u8BF7\u7801\u5DF2\u5220\u9664","settings.msg.deleteFailed":"\u5220\u9664\u5931\u8D25","settings.tabs.llm":"LLM","settings.tabs.yeaft":"Yeaft","settings.yeaft.tabs.vp":"VP \u5E93","settings.yeaft.tabs.search":"\u641C\u7D22","settings.yeaft.tabs.mcp":"MCP","settings.mcp.title":"MCP \u670D\u52A1\u5668","settings.mcp.description":"\u901A\u8FC7 Model Context Protocol \u7ED9 Yeaft \u63A5\u5165\u66F4\u591A\u5DE5\u5177\u3002\u914D\u7F6E\u5199\u5165 agent \u4E0A\u7684 ~/.yeaft/config.json\uFF0C\u5DE5\u5177\u4F1A\u4EE5 mcp__<server>__<tool> \u7684\u5F62\u5F0F\u51FA\u73B0\u5728 LLM \u5DE5\u5177\u5217\u8868\u91CC\u3002","settings.mcp.reloadAll":"\u5168\u90E8\u91CD\u8FDE","settings.mcp.reloadOne":"\u91CD\u65B0\u8FDE\u63A5\u6B64\u670D\u52A1\u5668","settings.mcp.loading":"\u5904\u7406\u4E2D\u2026","settings.mcp.connected":"\u5DF2\u8FDE\u63A5","settings.mcp.disconnected":"\u672A\u8FDE\u63A5","settings.mcp.tools":"\u4E2A\u5DE5\u5177","settings.mcp.remove":"\u79FB\u9664","settings.mcp.empty":"\u8FD8\u6CA1\u6709\u914D\u7F6E MCP \u670D\u52A1\u5668\uFF0C\u53EF\u4EE5\u5728\u4E0B\u65B9\u6DFB\u52A0\u4E00\u4E2A\u3002","settings.mcp.addServer":"\u6DFB\u52A0\u670D\u52A1\u5668","settings.mcp.addServerDesc":"\u5927\u90E8\u5206 MCP \u670D\u52A1\u5668\u662F\u672C\u5730\u547D\u4EE4 \u2014 Yeaft \u4F1A\u901A\u8FC7 stdio \u542F\u52A8\u5B83\u5E76\u81EA\u52A8\u53D1\u73B0\u53EF\u7528\u5DE5\u5177\u3002","settings.mcp.serverName":"\u540D\u79F0","settings.mcp.command":"\u547D\u4EE4","settings.mcp.args":"\u53C2\u6570","settings.mcp.argsPlaceholder":"\u4F8B\u5982\uFF1A-y @modelcontextprotocol/server-filesystem /tmp","settings.mcp.env":"\u73AF\u5883\u53D8\u91CF","settings.mcp.envPlaceholder":"\u6BCF\u884C\u4E00\u4E2A KEY=value\uFF0C# \u5F00\u5934\u7684\u884C\u4F1A\u88AB\u5FFD\u7565\u3002","settings.mcp.saving":"\u4FDD\u5B58\u4E2D\u2026","settings.mcp.add":"\u6DFB\u52A0","settings.mcp.cancel":"\u6E05\u7A7A","settings.mcp.connectFailed":"\u5DF2\u4FDD\u5B58\u4F46\u8FDE\u63A5\u5931\u8D25","settings.mcp.addSuccess":"\u670D\u52A1\u5668\u5DF2\u6DFB\u52A0","settings.mcp.removeSuccess":"\u670D\u52A1\u5668\u5DF2\u79FB\u9664","settings.mcp.reloadSuccess":"\u5DF2\u8BF7\u6C42\u91CD\u8FDE","settings.mcp.confirmRemove":'\u79FB\u9664 MCP \u670D\u52A1\u5668 "{name}"\uFF1F\u4E0B\u4E00\u4E2A LLM turn \u8D77\u5B83\u7684\u5DE5\u5177\u5C06\u4E0D\u518D\u53EF\u89C1\u3002',"settings.mcp.errors.nameRequired":"\u8BF7\u586B\u5199\u540D\u79F0","settings.mcp.errors.nameFormat":"\u540D\u79F0\u53EA\u80FD\u5305\u542B\u5C0F\u5199\u5B57\u6BCD\u3001\u6570\u5B57\u3001\u77ED\u6A2A\u7EBF\u548C\u4E0B\u5212\u7EBF","settings.mcp.errors.commandRequired":"\u8BF7\u586B\u5199\u547D\u4EE4","settings.mcp.errors.argsParse":"\u53C2\u6570\u89E3\u6790\u5931\u8D25","settings.mcp.errors.envParse":"\u73AF\u5883\u53D8\u91CF\u89E3\u6790\u5931\u8D25","yeaft.session.title":"\u4F1A\u8BDD","yeaft.session.new":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.title":"\u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.create.subtitle":"\u9009\u62E9\u8FD0\u884C\u4F4D\u7F6E\u548C\u5904\u7406\u4F1A\u8BDD\u7684 Provider\u3002","yeaft.session.create.close":"\u5173\u95ED","yeaft.session.create.nameLabel":"\u540D\u79F0","yeaft.session.create.namePlaceholder":"\u4F1A\u8BDD\u540D\u79F0\uFF08\u53EF\u9009\uFF09","yeaft.session.create.workDirLabel":"\u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.agentLabel":"Agent","yeaft.session.create.vpPicker":"\u9009\u62E9 VP","yeaft.session.create.vpNone":"\u672A\u9009\u62E9 VP","yeaft.session.create.vpCount":"\u5DF2\u9009 {n} \u4E2A VP","yeaft.session.create.untitled":"\u672A\u547D\u540D\u4F1A\u8BDD","yeaft.session.create.rosterEmpty":"\u6682\u65E0\u53EF\u7528 VP \u2014 \u8BF7\u5148\u5230\u89D2\u8272\u5E93\u521B\u5EFA\u3002","yeaft.session.create.rosterLoading":"VP \u52A0\u8F7D\u4E2D\u2026","yeaft.session.create.rosterError":"\u65E0\u6CD5\u4ECE\u5F53\u524D Agent \u52A0\u8F7D VP\u3002","yeaft.session.create.rosterRetry":"\u91CD\u8BD5","yeaft.vp.domain.general":"\u901A\u7528\u4E0E\u534F\u4F5C","yeaft.vp.domain.productDesign":"\u4EA7\u54C1\u4E0E\u4F53\u9A8C\u8BBE\u8BA1","yeaft.vp.domain.softwareSystems":"\u8F6F\u4EF6\u4E0E\u7CFB\u7EDF","yeaft.vp.domain.securityReliability":"\u5B89\u5168\u4E0E\u53EF\u9760\u6027","yeaft.vp.domain.scienceAnalysis":"\u79D1\u5B66\u4E0E\u5206\u6790","yeaft.vp.domain.philosophyPsychology":"\u54F2\u5B66\u4E0E\u5FC3\u7406","yeaft.vp.domain.strategyHistory":"\u6218\u7565\u4E0E\u5386\u53F2","yeaft.vp.domain.businessManagement":"\u5546\u4E1A\u4E0E\u7BA1\u7406","yeaft.vp.domain.artsCulture":"\u827A\u672F\u4E0E\u6587\u5316","yeaft.vp.domain.other":"\u5176\u4ED6\u9886\u57DF","yeaft.vp.domain.custom":"\u81EA\u5B9A\u4E49 VP","yeaft.session.create.defaultVpHint":"\u5F53\u6CA1\u6709 @ \u63D0\u53CA\u65F6\u9ED8\u8BA4\u56DE\u7B54\u7684 VP\u3002","yeaft.session.create.folderLabel":"\u{1F4C1} \u5DE5\u4F5C\u76EE\u5F55","yeaft.session.create.sessionLabel":"\u{1F4AC} \u6B64\u76EE\u5F55\u4E0B\u7684 session","yeaft.session.create.noWorkDirs":"\u8FD8\u6CA1\u6709\u4EFB\u4F55\u4F1A\u8BDD \u2014 \u5728\u4E0A\u65B9\u9009\u62E9\u6216\u8F93\u5165\u5DE5\u4F5C\u76EE\u5F55\u5F00\u59CB\u3002","yeaft.session.create.back":"\u8FD4\u56DE","yeaft.session.create.creating":"\u521B\u5EFA\u4E2D\u2026","yeaft.session.create.submit":"\u521B\u5EFA","yeaft.onboarding.ariaLabel":"Yeaft \u4E0A\u624B\u8BF4\u660E","yeaft.onboarding.topbarTitle":"\u5F00\u59CB\u4F7F\u7528 Yeaft","yeaft.onboarding.eyebrow":"Yeaft \u4E0A\u624B\u6307\u5357","yeaft.onboarding.title":"\u5148\u8FDE\u63A5 Agent\uFF0C\u518D\u5F00\u59CB\u4F1A\u8BDD","yeaft.onboarding.subtitle":"\u5728\u8D1F\u8D23\u6267\u884C\u5DE5\u5177\u7684\u673A\u5668\u4E0A\u76F4\u63A5\u8FD0\u884C\u4E0B\u9762\u7684\u547D\u4EE4\u3002agent secret \u5982\u679C\u4E0D\u5B58\u5728\uFF0C\u4F1A\u81EA\u52A8\u4E3A\u5F53\u524D\u8D26\u53F7\u751F\u6210\u3002","yeaft.onboarding.createSession":"\u521B\u5EFA\u6216\u6062\u590D Session","yeaft.onboarding.configureLlm":"\u6253\u5F00 LLM \u8BBE\u7F6E","yeaft.onboarding.secretLoading":"\u6B63\u5728\u751F\u6210 agent secret\u2026","yeaft.onboarding.secretError":"\u52A0\u8F7D agent secret \u5931\u8D25\u3002","yeaft.onboarding.secretPending":"<\u6B63\u5728\u52A0\u8F7D-agent-secret>","yeaft.onboarding.installTitle":"\u5B89\u88C5 yeaft-agent","yeaft.onboarding.installDesc":"\u5B89\u88C5\u547D\u4EE4\u884C Agent \u5305\u3002","yeaft.onboarding.connectTitle":"\u8FDE\u63A5\u8FD9\u4E2A Agent","yeaft.onboarding.connectDesc":"\u4E0B\u9762\u7684\u547D\u4EE4\u5DF2\u7ECF\u5E26\u4E0A\u5F53\u524D server URL \u548C\u81EA\u52A8\u751F\u6210\u7684 secret\u3002","yeaft.onboarding.llmTitle":"\u4F7F\u7528 GitHub Copilot","yeaft.onboarding.llmDesc":"\u5148\u767B\u5F55 GitHub CLI\uFF0C\u7136\u540E\u628A gpt-5.5 \u8BBE\u4E3A Yeaft \u9ED8\u8BA4\u6A21\u578B\u3002","yeaft.restore.modal.empty":"\u6B64\u76EE\u5F55\u4E0B\u6CA1\u6709 yeaft session","yeaft.restore.modal.scanError":"\u626B\u63CF\u5931\u8D25: {message}","yeaft.restore.modal.restoreError":"\u6062\u590D\u5931\u8D25: {message}","settings.llm.noAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent \u4EE5\u7BA1\u7406 LLM \u914D\u7F6E\u3002","settings.llm.agentOffline":"Agent \u5F53\u524D\u79BB\u7EBF\uFF0C\u65E0\u6CD5\u52A0\u8F7D LLM \u914D\u7F6E\u3002\u8BF7\u7B49\u5F85 Agent \u4E0A\u7EBF\u540E\u91CD\u8BD5\u3002","settings.llm.loading":"\u6B63\u5728\u52A0\u8F7D\u914D\u7F6E...","settings.llm.loadError":"\u52A0\u8F7D\u914D\u7F6E\u5931\u8D25","settings.llm.configureAgent":"\u914D\u7F6E\u5F53\u524D Agent \u7684 LLM","settings.llm.configureMenu":"\u8BBE\u7F6E LLM","settings.llm.simpleCopilotTitle":"\u63A8\u8350\uFF1AGitHub Copilot","settings.llm.useGitHubCopilot":"\u4F7F\u7528 GitHub Copilot","settings.llm.refreshingModels":"\u6B63\u5728\u5237\u65B0\u6A21\u578B...","settings.llm.managedCopilotTitle":"\u6258\u7BA1\u7684 GitHub Copilot","settings.llm.managedCopilotDesc":"Base URL\u3001\u8BA4\u8BC1\u3001\u6A21\u578B\u76EE\u5F55\u548C\u6BCF\u4E2A\u6A21\u578B\u7684 API \u534F\u8BAE\u90FD\u81EA\u52A8\u7BA1\u7406\u3002Claude \u6A21\u578B\u8D70 Anthropic Messages\uFF1BGPT/o \u6A21\u578B\u8D70 OpenAI Responses\u3002","settings.llm.providersTitle":"\u670D\u52A1\u5546","settings.llm.testFailed":"\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25","settings.llm.saveSuccess":"LLM \u8BBE\u7F6E\u5DF2\u4FDD\u5B58","settings.llm.saveFailed":"\u4FDD\u5B58 LLM \u8BBE\u7F6E\u5931\u8D25","settings.llm.presets.title":"\u5FEB\u901F\u914D\u7F6E","settings.llm.providersDesc":"\u9009\u62E9\u4E00\u4E2A\u670D\u52A1\u5546\uFF0C\u4FDD\u5B58\u540E\u5373\u53EF\u5728 Session \u4E2D\u4F7F\u7528\u3002","settings.llm.agentProviders":"\u5F53\u524D agent providers","settings.llm.agentBadge":"\u5F53\u524D agent","settings.llm.addProvider":"\u6DFB\u52A0\u670D\u52A1\u5546","settings.llm.addFromPreset":"\u4ECE\u76EE\u5F55\u6DFB\u52A0","settings.llm.preset.title":"\u670D\u52A1\u5546\u76EE\u5F55\uFF08models.dev\uFF09","settings.llm.preset.refresh":"\u5237\u65B0\u76EE\u5F55","settings.llm.preset.loading":"\u52A0\u8F7D\u76EE\u5F55\u2026","settings.llm.preset.empty":"\u76EE\u5F55\u4E3A\u7A7A\u3002","settings.llm.preset.pickProvider":"\u5728\u5DE6\u4FA7\u9009\u62E9\u4E00\u4E2A\u670D\u52A1\u5546\u4EE5\u67E5\u770B\u6A21\u578B\u3002","settings.llm.preset.filterProviders":"\u8FC7\u6EE4\u670D\u52A1\u5546\u2026","settings.llm.preset.filterModels":"\u8FC7\u6EE4\u6A21\u578B\u2026","settings.llm.preset.selectAll":"\u5168\u9009","settings.llm.preset.selectNone":"\u6E05\u7A7A","settings.llm.preset.cancel":"\u53D6\u6D88","settings.llm.preset.add":"\u6DFB\u52A0\u5230\u670D\u52A1\u5546\u5217\u8868","settings.llm.preset.fetchedAt":"\u76EE\u5F55\u5DF2\u66F4\u65B0 {minutes} \u5206\u949F","settings.llm.addModel":"\u6DFB\u52A0\u6A21\u578B","settings.llm.removeModel":"\u79FB\u9664\u6A21\u578B","settings.llm.providerName":"\u540D\u79F0","settings.llm.providerNamePlaceholder":"\u4F8B\u5982 my-proxy","settings.llm.baseUrl":"Base URL","settings.llm.baseUrlPlaceholder":"\u4F8B\u5982 http://localhost:6628/v1","settings.llm.apiKey":"API Key","settings.llm.apiKeyPlaceholder":"\u8F93\u5165 API Key","settings.llm.protocol":"\u534F\u8BAE","settings.llm.protocolOpenAI":"OpenAI \u517C\u5BB9","settings.llm.protocolOpenAIResponses":"OpenAI Responses (GPT-5)","settings.llm.protocolAnthropic":"Anthropic \u539F\u751F","settings.llm.protocolHint.anthropic":"Claude \u539F\u751F Messages API\u3002","settings.llm.protocolHint.openai":"Chat Completions /v1/chat/completions \u2014 GPT-4 \u53CA\u5927\u591A\u6570\u517C\u5BB9\u4EE3\u7406\u3002","settings.llm.protocolHint.openaiResponses":"Responses API /v1/responses \u2014 GPT-5 \u7CFB\u5217\u5FC5\u987B\u3002","settings.llm.modelCtxPlaceholder":"\u4E0A\u4E0B\u6587","settings.llm.modelMaxPlaceholder":"\u8F93\u51FA","settings.llm.models":"\u5019\u9009\u6A21\u578B ID","settings.llm.modelsPlaceholder":"\u6A21\u578B ID\uFF0C\u9017\u53F7\u6216\u6362\u884C\u5206\u9694\uFF0C\u4F8B\u5982 claude-sonnet-4-20250514, gpt-5","settings.llm.modelsHint":"\u9017\u53F7\u6216\u6362\u884C\u5206\u9694\u3002","settings.llm.removeProvider":"\u79FB\u9664","settings.llm.modelSelectionTitle":"\u6A21\u578B\u9009\u62E9","settings.llm.modelSelectionDesc":"\u9009\u62E9\u9ED8\u8BA4\u6A21\u578B\u3002","settings.llm.primaryModel":"\u4E3B\u6A21\u578B","settings.llm.primaryModelDesc":"\u7528\u4E8E\u7528\u6237\u5BF9\u8BDD","settings.llm.fastModel":"\u5FEB\u901F\u6A21\u578B","settings.llm.fastModelDesc":"\u7528\u4E8E\u5185\u90E8\u4EFB\u52A1\uFF08\u8BB0\u5FC6\u3001\u603B\u7ED3\uFF09","settings.llm.noModels":"\u6682\u65E0\u53EF\u7528\u6A21\u578B\u3002\u8BF7\u5148\u6DFB\u52A0\u670D\u52A1\u5546\u3002","settings.llm.selectModel":"\u9009\u62E9\u6A21\u578B...","settings.llm.save":"\u4FDD\u5B58\u66F4\u6539","settings.llm.saving":"\u4FDD\u5B58\u4E2D...","settings.llm.saved":"\u914D\u7F6E\u5DF2\u4FDD\u5B58","settings.llm.savedRefreshWarning":"\u914D\u7F6E\u5DF2\u4FDD\u5B58\uFF0C\u4F46\u5B9E\u65F6\u6A21\u578B\u76EE\u5F55\u5237\u65B0\u5931\u8D25\uFF1A{error}","settings.llm.unsavedChanges":"\u6709\u672A\u4FDD\u5B58\u7684\u66F4\u6539","settings.llm.confirmRemoveProvider":"\u786E\u5B9A\u79FB\u9664\u6B64\u670D\u52A1\u5546\uFF1F","settings.llm.setupTitle":"\u8FDE\u63A5\u6A21\u578B","settings.llm.setupDesc":"\u63A8\u8350\u4F7F\u7528 GitHub Copilot\uFF1B\u4E5F\u53EF\u4EE5\u6DFB\u52A0\u81EA\u5DF1\u7684 API \u670D\u52A1\u5546\u3002","settings.llm.providerSectionHint":"\u53EA\u4FDD\u7559\u8FDE\u63A5\u6A21\u578B\u5FC5\u9700\u7684\u4FE1\u606F\u3002","settings.tabs.dashboard":"\u4EEA\u8868\u677F","settings.dashboard.totalUsers":"\u603B\u7528\u6237\u6570","settings.dashboard.onlineUsers":"\u5728\u7EBF\u7528\u6237","settings.dashboard.onlineAgents":"\u5728\u7EBFAgent","settings.dashboard.totalSessions":"\u603B\u4F1A\u8BDD\u6570","settings.dashboard.todayActive":"\u4ECA\u65E5\u6D3B\u8DC3","settings.dashboard.todayMessages":"\u4ECA\u65E5\u6D88\u606F","settings.dashboard.todayUserTurns":"\u4ECA\u65E5\u7528\u6237 Turn","settings.dashboard.totalTokens":"\u603B Token","settings.dashboard.tokenAccuracy":"\u6765\u81EA\u6A21\u578B\u670D\u52A1\u5546\u8FD4\u56DE\u7684\u5B9E\u9645\u7528\u91CF\uFF1B\u4ECE\u542F\u7528\u6309\u7528\u6237 Token \u7EDF\u8BA1\u7684\u7248\u672C\u5F00\u59CB\u7D2F\u8BA1\uFF0C\u4E14\u4E0D\u5305\u542B\u5FC3\u8DF3\u3002","settings.dashboard.agentTurns":"Agent Turn","settings.dashboard.agentSessions":"Agent Session","settings.dashboard.turns":"Turn","settings.dashboard.tokens":"Token","settings.dashboard.inputTokens":"\u8F93\u5165","settings.dashboard.outputTokens":"\u8F93\u51FA","settings.dashboard.cacheTokens":"\u7F13\u5B58","settings.dashboard.today":"\u4ECA\u5929","settings.dashboard.thisWeek":"\u672C\u5468","settings.dashboard.thisMonth":"\u672C\u6708","settings.dashboard.all":"\u5168\u90E8","settings.dashboard.userUsage":"\u7528\u6237\u7528\u91CF","settings.dashboard.agentList":"Agent \u5217\u8868","settings.dashboard.onlineUserList":"\u5728\u7EBF\u7528\u6237","settings.dashboard.refresh":"\u5237\u65B0","settings.dashboard.name":"\u540D\u79F0","settings.dashboard.messages":"\u6D88\u606F\u6570","settings.dashboard.userTurns":"\u7528\u6237 Turn \u6570","settings.dashboard.sessions":"\u4F1A\u8BDD\u6570","settings.dashboard.requests":"\u8BF7\u6C42\u6570","settings.dashboard.traffic":"\u6D41\u91CF","settings.dashboard.lastLogin":"\u6700\u540E\u767B\u5F55","settings.dashboard.status":"\u72B6\u6001","settings.dashboard.latency":"\u5EF6\u8FDF","settings.dashboard.version":"\u7248\u672C","settings.dashboard.owner":"\u6240\u6709\u8005","settings.dashboard.role":"\u89D2\u8272","settings.dashboard.agent":"Agent","settings.dashboard.online":"\u5728\u7EBF","settings.dashboard.offline":"\u79BB\u7EBF","settings.dashboard.noAgents":"\u6682\u65E0\u6CE8\u518C Agent","settings.dashboard.noUserData":"\u6682\u65E0\u7528\u6237\u6570\u636E","settings.dashboard.noOnlineUsers":"\u6682\u65E0\u5728\u7EBF\u7528\u6237","settings.dashboard.loading":"\u52A0\u8F7D\u4E2D...","settings.dashboard.error":"\u6570\u636E\u52A0\u8F7D\u5931\u8D25","settings.dashboard.ago":"{time}\u524D","settings.dashboard.loadMore":"\u52A0\u8F7D\u66F4\u591A\uFF08\u5269\u4F59 {remaining} \u6761\uFF09","workbench.maximize":"\u6700\u5927\u5316\u9762\u677F","workbench.restore":"\u8FD8\u539F\u9762\u677F","workbench.collapse":"\u6536\u8D77\u9762\u677F","theme.switchToLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.switchToDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","theme.toLight":"\u5207\u6362\u5230\u6D45\u8272\u4E3B\u9898","theme.toDark":"\u5207\u6362\u5230\u6DF1\u8272\u4E3B\u9898","terminal.splitH":"\u6C34\u5E73\u5206\u5C4F\uFF08\u5DE6\u53F3\uFF09","terminal.splitV":"\u5782\u76F4\u5206\u5C4F\uFF08\u4E0A\u4E0B\uFF09","terminal.close":"\u5173\u95ED\u5F53\u524D\u7EC8\u7AEF","terminal.autoCreate":"\u5207\u6362\u5230 Terminal \u6807\u7B7E\u65F6\u5C06\u81EA\u52A8\u521B\u5EFA\u7EC8\u7AEF","terminal.xtermError":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.xtermNotLoaded":"xterm.js \u672A\u52A0\u8F7D\uFF0C\u8BF7\u5237\u65B0\u9875\u9762","terminal.mountError":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.mountFailed":"\u7EC8\u7AEF\u5BB9\u5668\u6302\u8F7D\u5931\u8D25","terminal.createError":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.createFailed":"\u7EC8\u7AEF\u521B\u5EFA\u5931\u8D25","terminal.error":"\u7EC8\u7AEF\u9519\u8BEF","git.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","git.repoPath":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.repoPathPlaceholder":"\u8F93\u5165 Git \u4ED3\u5E93\u8DEF\u5F84...","git.workDir":"Git \u5DE5\u4F5C\u76EE\u5F55","git.loadStatus":"\u52A0\u8F7D Git \u72B6\u6001","git.loading":"\u52A0\u8F7D Git \u72B6\u6001...","git.loadingStatus":"\u52A0\u8F7D Git \u72B6\u6001...","git.clean":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.cleanWorkDir":"\u5DE5\u4F5C\u533A\u5E72\u51C0\uFF0C\u65E0\u53D8\u66F4","git.selectAgent":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.selectAgentFirst":"\u9009\u62E9 Agent \u540E\u52A0\u8F7D Git \u72B6\u6001","git.diffOnly":"\u53EA\u770B\u5DEE\u5F02","git.fullFile":"\u770B\u5168\u6587","git.zoomIn":"\u653E\u5927\u5B57\u4F53","git.zoomOut":"\u7F29\u5C0F\u5B57\u4F53","git.loadingDiff":"\u52A0\u8F7D Diff...","git.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.clickFileToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5DEE\u5F02","git.selectRepo":"\u9009\u62E9 Git \u4ED3\u5E93","git.noDiff":"(\u65E0\u5DEE\u5F02)","git.binaryFile":"(\u4E8C\u8FDB\u5236\u6587\u4EF6)","files.notLoaded":"\u672A\u52A0\u8F7D","files.newFile":"\u65B0\u5EFA\u6587\u4EF6","files.newFolder":"\u65B0\u5EFA\u6587\u4EF6\u5939","files.collapseAll":"\u6298\u53E0\u6240\u6709","files.openFolder":"\u6253\u5F00\u6587\u4EF6\u5939","files.deleteSelected":"\u5220\u9664\u9009\u4E2D","files.moveSelected":"\u79FB\u52A8\u9009\u4E2D","files.enterPath":"\u8F93\u5165\u8DEF\u5F84...","files.searchFiles":"\u641C\u7D22\u6587\u4EF6... (Ctrl+P)","files.noMatch":"\u65E0\u5339\u914D\u7ED3\u679C","files.searching":"\u641C\u7D22\u4E2D...","files.loadingTree":"\u52A0\u8F7D\u4E2D...","files.emptyDir":"\u7A7A\u76EE\u5F55","files.loadingFile":"\u52A0\u8F7D\u6587\u4EF6...","files.searchPlaceholder":"\u641C\u7D22...","files.replacePlaceholder":"\u66FF\u6362...","files.replace":"\u66FF\u6362","files.replaceAll":"\u5168\u90E8","files.replaceCurrent":"\u66FF\u6362\u5F53\u524D","files.replaceAllTitle":"\u5168\u90E8\u66FF\u6362","files.clickToView":"\u70B9\u51FB\u6587\u4EF6\u67E5\u770B\u5185\u5BB9","files.selectFolder":"\u9009\u62E9\u6587\u4EF6\u5939","files.enterFolderName":"\u8F93\u5165\u6587\u4EF6\u5939\u540D...","files.enterFileName":"\u8F93\u5165\u6587\u4EF6\u540D...","files.moveTarget":"\u8F93\u5165\u76EE\u6807\u76EE\u5F55\u8DEF\u5F84...","files.moveItems":"\u5C06 {count} \u4E2A\u9879\u76EE\u79FB\u52A8\u5230\u6307\u5B9A\u76EE\u5F55","files.workDir":"\u5DE5\u4F5C\u76EE\u5F55: {dir}","files.enterDirPath":"\u8F93\u5165\u76EE\u5F55\u8DEF\u5F84...","files.unsavedConfirm":'"{name}" \u6709\u672A\u4FDD\u5B58\u7684\u4FEE\u6539\uFF0C\u786E\u5B9A\u5173\u95ED\uFF1F',"files.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664 "{name}" \u5417\uFF1F',"files.deleteDirHint":"\uFF08\u5C06\u5220\u9664\u6587\u4EF6\u5939\u53CA\u5176\u6240\u6709\u5185\u5BB9\uFF09","files.deleteSelectedConfirm":"\u786E\u5B9A\u8981\u5220\u9664\u9009\u4E2D\u7684 {count} \u4E2A\u9879\u76EE\u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","files.findPrev":"\u4E0A\u4E00\u4E2A (Shift+Enter)","files.findNext":"\u4E0B\u4E00\u4E2A (Enter)","files.caseSensitive":"\u533A\u5206\u5927\u5C0F\u5199","files.regex":"\u6B63\u5219\u8868\u8FBE\u5F0F","files.unsaved":"\u672A\u4FDD\u5B58","files.clearSelection":"\u6E05\u9664\u9009\u62E9","files.rename":"\u91CD\u547D\u540D","files.copyHere":"\u590D\u5236","files.moveTo":"\u79FB\u52A8\u5230...","files.download":"\u4E0B\u8F7D","files.enterNewName":"\u8F93\u5165\u65B0\u540D\u79F0...","files.loadingPreview":"\u52A0\u8F7D\u9884\u89C8\u4E2D...","files.preview":"\u9884\u89C8","files.edit":"\u7F16\u8F91","files.pptxNotSupported":"PPTX \u672C\u5730\u9884\u89C8\u6682\u4E0D\u652F\u6301\uFF0C\u8BF7\u5728\u8BBE\u7F6E\u4E2D\u5207\u6362\u4E3A Office Online \u6A21\u5F0F\u3002","files.officePreviewMode":"Office \u9884\u89C8\u6A21\u5F0F","files.officeOnline":"Office Online","files.localRender":"\u672C\u5730\u6E32\u67D3","proxy.port":"\u7AEF\u53E3","proxy.label":"\u6807\u7B7E","proxy.add":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.addPort":"\u6DFB\u52A0\u7AEF\u53E3\u6620\u5C04","proxy.enable":"\u70B9\u51FB\u542F\u7528","proxy.clickEnable":"\u70B9\u51FB\u542F\u7528","proxy.disable":"\u70B9\u51FB\u7981\u7528","proxy.clickDisable":"\u70B9\u51FB\u7981\u7528","proxy.openNewTab":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.openInBrowser":"\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00","proxy.noMappings":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.noPorts":"\u6682\u65E0\u7AEF\u53E3\u6620\u5C04","proxy.hint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.noPortsHint":"\u6DFB\u52A0\u7AEF\u53E3\u540E\uFF0C\u53EF\u901A\u8FC7\u4EE3\u7406 URL \u8BBF\u95EE agent \u673A\u5668\u4E0A\u7684\u672C\u5730\u670D\u52A1","proxy.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.selectAgent":"\u8BF7\u5148\u9009\u62E9\u4E00\u4E2A Agent","store.creatingConv":"\u6B63\u5728\u521B\u5EFA\u4F1A\u8BDD...","store.loadingHistory":"\u6B63\u5728\u52A0\u8F7D\u4F1A\u8BDD\u5386\u53F2...","store.executionCancelled":"\u6267\u884C\u5DF2\u53D6\u6D88","store.loginFailed":"\u767B\u5F55\u5931\u8D25","store.convClosed":"\u4F1A\u8BDD\u5DF2\u5173\u95ED","store.convCreated":"\u65B0\u4F1A\u8BDD\u5DF2\u521B\u5EFA [{agent}]\uFF0C\u5DE5\u4F5C\u76EE\u5F55: {workDir}","store.convResumed":"\u5DF2\u6062\u590D\u4F1A\u8BDD [{agent}]: {sessionId}","roleplay.creating":"\u6B63\u5728\u521B\u5EFA \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.working":"\u5DE5\u4F5C\u4E2D","roleplay.selectTeam":"\u9009\u62E9\u56E2\u961F\u6A21\u677F","roleplay.teamDev":"\u8F6F\u4EF6\u5F00\u53D1","roleplay.teamCustom":"\u81EA\u5B9A\u4E49","roleplay.editRoles":"\u7F16\u8F91\u89D2\u8272","roleplay.roleName":"\u89D2\u8272\u6807\u8BC6","roleplay.roleDisplayName":"\u663E\u793A\u540D\u79F0","roleplay.roleIcon":"\u56FE\u6807","roleplay.roleDesc":"\u89D2\u8272\u63CF\u8FF0","roleplay.rolePrompt":"\u89D2\u8272 Prompt","roleplay.removeRole":"\u79FB\u9664\u89D2\u8272","roleplay.addRole":"\u6DFB\u52A0\u89D2\u8272","roleplay.start":"\u542F\u52A8 \u89D2\u8272\u626E\u6F14","roleplay.sidebarTitle":"\u89D2\u8272\u626E\u6F14","roleplay.configTitle":"\u89D2\u8272\u626E\u6F14","roleplay.newSession":"\u65B0\u5EFA \u89D2\u8272\u626E\u6F14","roleplay.emptyHint":"\u53D1\u9001\u6D88\u606F\u5F00\u59CB\u591A\u89D2\u8272\u534F\u4F5C","roleplay.askingYou":"\u6B63\u5728\u63D0\u95EE","roleplay.language":"\u8BED\u8A00","roleplay.rolePreview":"\u89D2\u8272\u914D\u7F6E","roleplay.noAgents":"\u6CA1\u6709\u5728\u7EBF\u7684 Agent","roleplay.inputPlaceholder":"\u8F93\u5165\u6D88\u606F\u2026 \u4F7F\u7528 @ \u63D0\u53CA\u89D2\u8272","roleplay.existingSessions":"\u5DF2\u6709\u56E2\u961F","roleplay.restore":"\u6062\u590D","roleplay.restoring":"\u6B63\u5728\u6062\u590D \u89D2\u8272\u626E\u6F14 \u4F1A\u8BDD...","roleplay.createNew":"\u521B\u5EFA\u65B0\u56E2\u961F","expertPanel.title":"\u5E2E\u5E2E\u56E2","expertPanel.search":"\u641C\u7D22\u89D2\u8272\u6216 Action...","expertPanel.noResults":"\u6CA1\u6709\u5339\u914D\u7ED3\u679C","expertPanel.clearAll":"\u6E05\u7A7A","expertPanel.persona":"\u89D2\u8272\u4EBA\u8BBE","expertPanel.template":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00","expertPanel.templateHint":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF1A\u6B64\u524D\u7F00 + \u7528\u6237\u6587\u5B57 = \u6700\u7EC8\u53D1\u9001\u5185\u5BB9","expertPanel.defaultMsg":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt","expertPanel.defaultMsgHint":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574 prompt","expertPanel.loading":"\u6B63\u5728\u52A0\u8F7D\u89D2\u8272\u5B9A\u4E49...","expertPanel.viewPrompt":"\u67E5\u770B\u63D0\u793A\u8BCD","expertPanel.customRoles":"\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.addRole":"\u6DFB\u52A0\u89D2\u8272","expertPanel.editRole":"\u7F16\u8F91\u89D2\u8272","expertPanel.deleteRole":"\u5220\u9664\u89D2\u8272","expertPanel.noCustomRoles":"\u6682\u65E0\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.createFirst":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u81EA\u5B9A\u4E49\u89D2\u8272","expertPanel.noActions":"\u6682\u65E0 Action","expertPanel.deleteConfirm":'\u786E\u5B9A\u8981\u5220\u9664\u89D2\u8272 "{name}" \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002',"expertPanel.deleteConfirmBtn":"\u5220\u9664","expertEditor.createTitle":"\u521B\u5EFA\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.editTitle":"\u7F16\u8F91\u81EA\u5B9A\u4E49\u89D2\u8272","expertEditor.basicInfo":"\u57FA\u672C\u4FE1\u606F","expertEditor.roleName":"\u89D2\u8272\u540D\u79F0","expertEditor.roleNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790\u5E08","expertEditor.roleTitle":"\u804C\u79F0","expertEditor.roleTitlePlaceholder":"\u5982\uFF1A\u9AD8\u7EA7\u6570\u636E\u5206\u6790\u5E08","expertEditor.fullName":"\u5168\u540D","expertEditor.fullNamePlaceholder":"\u53EF\u9009","expertEditor.titleEn":"\u82F1\u6587\u804C\u79F0","expertEditor.titleEnPlaceholder":"\u53EF\u9009","expertEditor.rolePrompt":"\u89D2\u8272 Prompt","expertEditor.messagePrefix":"\u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messagePrefixPlaceholder":"\u5982\uFF1A\u4F5C\u4E3A\u4E00\u540D\u8D44\u6DF1\u6570\u636E\u5206\u6790\u5E08\uFF0C","expertEditor.messagePrefixEn":"\u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messagePrefixEnPlaceholder":"As a senior data analyst, ","expertEditor.actions":"Actions","expertEditor.addAction":"\u6DFB\u52A0 Action","expertEditor.removeAction":"\u79FB\u9664","expertEditor.actionName":"Action \u540D\u79F0","expertEditor.actionNamePlaceholder":"\u5982\uFF1A\u6570\u636E\u5206\u6790","expertEditor.actionNameEn":"\u82F1\u6587\u540D\u79F0","expertEditor.actionNameEnPlaceholder":"\u53EF\u9009","expertEditor.messageTemplate":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u4E2D\u6587\uFF09","expertEditor.messageTemplatePlaceholder":"\u7528\u6237\u5199\u4E86\u6587\u5B57\u65F6\uFF0C\u62FC\u5728\u7528\u6237\u6587\u5B57\u524D\u9762\u53D1\u9001","expertEditor.messageTemplateEn":"\u6709\u8F93\u5165\u65F6 \xB7 \u6D88\u606F\u524D\u7F00\uFF08\u82F1\u6587\uFF09","expertEditor.messageTemplateEnPlaceholder":"Prepended to user text when user types something","expertEditor.defaultMessage":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u4E2D\u6587\uFF09","expertEditor.defaultMessagePlaceholder":"\u7528\u6237\u4E0D\u5199\u6587\u5B57\u76F4\u63A5\u53D1\u9001\u65F6\uFF0C\u4F7F\u7528\u6B64\u5B8C\u6574\u5185\u5BB9","expertEditor.defaultMessageEn":"\u65E0\u8F93\u5165\u65F6 \xB7 \u5B8C\u6574 Prompt\uFF08\u82F1\u6587\uFF09","expertEditor.defaultMessageEnPlaceholder":"Used as-is when user sends without typing","expertEditor.cancel":"\u53D6\u6D88","expertEditor.save":"\u4FDD\u5B58","expertEditor.saving":"\u4FDD\u5B58\u4E2D...","subAgentPanel.title":"\u5B50\u4EE3\u7406","subAgentPanel.back":"\u8FD4\u56DE\u5217\u8868","subAgentPanel.running":"\u8FD0\u884C\u4E2D","subAgentPanel.completed":"\u5DF2\u5B8C\u6210","subAgentPanel.waitingMessages":"\u7B49\u5F85\u6D88\u606F...","subAgentPanel.toolCount":"{count} \u4E2A\u5DE5\u5177","subAgentPanel.toolSummary":"\u5DF2\u5B8C\u6210 {count} \u6B21\u5DE5\u5177\u8C03\u7528","subAgentPanel.empty":"\u6682\u65E0\u5B50\u4EE3\u7406","subAgentPanel.emptyHint":"\u5F53 Claude \u59D4\u6D3E\u4EFB\u52A1\u65F6\uFF0C\u5B50\u4EE3\u7406\u4F1A\u5728\u8FD9\u91CC\u663E\u793A","splitScreen.split":"\u5206\u5C4F","splitScreen.closePane":"\u5173\u95ED\u6B64\u9762\u677F","splitScreen.newChat":"\u65B0\u5EFA Chat","splitScreen.noSessions":"\u6682\u65E0\u4F1A\u8BDD","splitScreen.splitToPanel":"\u5728\u65B0\u9762\u677F\u4E2D\u6253\u5F00","splitScreen.selectFromSidebar":"\u4ECE\u5DE6\u4FA7\u9009\u62E9\u5BF9\u8BDD","yeaft.vp.library":"\u89D2\u8272\u5E93","yeaft.vp.createFirst":"+ \u521B\u5EFA\u4F60\u7684\u7B2C\u4E00\u4E2A\u89D2\u8272","yeaft.vp.empty.aria":"\u5C1A\u65E0\u89D2\u8272","yeaft.vp.avatar.aria":"{name} \u5934\u50CF","yeaft.vp.speaker.stateCauseAria":"\u72B6\u6001\u53D8\u66F4\uFF1A{cause}","yeaft.vp.status.thinking":"\u6B63\u5728\u601D\u8003\u2026","yeaft.vp.status.tool":"\u6B63\u5728\u4F7F\u7528 {name}","yeaft.vp.status.done":"\u5B8C\u6210 \xB7 {count} \u4E2A\u5DE5\u5177","yeaft.vp.status.aborted":"\u5DF2\u4E2D\u6B62","yeaft.vp.crud.title":"\u89D2\u8272\u5E93","yeaft.vp.crud.close":"\u5173\u95ED","yeaft.vp.crud.addNew":"+ \u65B0\u5EFA\u89D2\u8272","yeaft.vp.crud.empty":"\u8FD8\u6CA1\u6709\u89D2\u8272\u3002\u521B\u5EFA\u7B2C\u4E00\u4E2A\u89D2\u8272\u5F00\u59CB\u534F\u4F5C\u5427\u3002","yeaft.vp.crud.edit":"\u7F16\u8F91","yeaft.vp.crud.delete":"\u5220\u9664","yeaft.vp.crud.deleteConfirm":'\u5220\u9664 "{name}"\uFF1F\u4F1A\u4E00\u5E76\u5220\u9664\u78C1\u76D8\u4E0A\u7684 role.md \u6587\u4EF6\u3002',"yeaft.vp.crud.form.create":"\u521B\u5EFA\u89D2\u8272","yeaft.vp.crud.form.update":"\u7F16\u8F91\u89D2\u8272","yeaft.vp.crud.form.vpId":"\u89D2\u8272 ID","yeaft.vp.crud.form.vpId.tooltip":"\u53EA\u80FD\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001- \u548C _\uFF0C\u4E0D\u80FD\u4EE5 _ \u5F00\u5934\uFF0C\u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\uFF0C\u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF1Aall / user / system / everyone\u3002","yeaft.vp.crud.form.displayName":"\u663E\u793A\u540D\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.displayNameZh":"\u663E\u793A\u540D\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.description":"\u80FD\u529B\u63CF\u8FF0\uFF08\u82F1\u6587\uFF09","yeaft.vp.crud.form.descriptionZh":"\u80FD\u529B\u63CF\u8FF0\uFF08\u4E2D\u6587\uFF09","yeaft.vp.crud.form.descriptionPlaceholder":"\u4F8B\u5982\uFF1AAPI design, migration planning, and compatibility reviews","yeaft.vp.crud.form.descriptionZhPlaceholder":"\u4F8B\u5982\uFF1AAPI \u8BBE\u8BA1\u3001\u8FC1\u79FB\u89C4\u5212\u4E0E\u517C\u5BB9\u6027\u8BC4\u5BA1","yeaft.vp.crud.form.role":"\u804C\u4F4D","yeaft.vp.crud.form.rolePlaceholder":"\u4F8B\u5982\uFF1A\u4EA7\u54C1\u7ECF\u7406","yeaft.vp.crud.form.traits":"\u7279\u8D28\u6807\u7B7E","yeaft.vp.crud.form.traitsHint":"\u7528\u82F1\u6587\u9017\u53F7\u5206\u9694\u7684\u77ED\u6807\u7B7E\uFF08\u4F8B\u5982\uFF1A\u597D\u5947, \u52A1\u5B9E\uFF09\u3002","yeaft.vp.crud.form.modelHint":"\u6A21\u578B\u504F\u597D","yeaft.vp.crud.form.modelHint.none":"\u2014 \u9ED8\u8BA4 \u2014","yeaft.vp.crud.form.modelHint.primary":"\u4E3B\u6A21\u578B","yeaft.vp.crud.form.modelHint.fast":"\u5FEB\u6A21\u578B","yeaft.vp.crud.form.persona":"\u4EBA\u8BBE\uFF08Markdown\uFF09","yeaft.vp.crud.form.personaPlaceholder":"\u63CF\u8FF0\u8FD9\u4E2A\u89D2\u8272\u5982\u4F55\u601D\u8003\u3001\u8868\u8FBE\u3001\u505A\u51B3\u7B56\u2026\u2026","yeaft.vp.crud.form.submit":"\u4FDD\u5B58","yeaft.vp.crud.form.cancel":"\u53D6\u6D88","yeaft.vp.crud.form.ok":"\u683C\u5F0F\u6B63\u786E","yeaft.vp.crud.form.idLocked":"\u521B\u5EFA\u540E\u89D2\u8272 ID \u4E0D\u53EF\u4FEE\u6539\u3002","yeaft.vp.crud.saving":"\u4FDD\u5B58\u4E2D\u2026\u2026","yeaft.vp.crud.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.deleteFailed":"\u5220\u9664\u5931\u8D25\uFF1A{error}","yeaft.vp.crud.viewPrompt":"\u67E5\u770B prompt","yeaft.vp.crud.view.title":"VP \u63D0\u793A\u8BCD","yeaft.vp.crud.view.personaEmpty":"\uFF08\u672A\u5B9A\u4E49 persona \u6B63\u6587\uFF0C\u53EA\u6709\u57FA\u7840\u5143\u6570\u636E\uFF09","yeaft.vp.crud.view.back":"\u8FD4\u56DE","yeaft.vp.crud.view.editFromHere":"\u7F16\u8F91\u8BE5 VP","yeaft.vp.crud.view.removed":"\u8BE5 VP \u5DF2\u5728\u522B\u5904\u88AB\u5220\u9664\uFF0C\u8FD4\u56DE\u5217\u8868\u3002","yeaft.vp.crud.stockBadge":"\u9884\u88C5","yeaft.vp.crud.stockReadOnly":"\u9884\u88C5 VP \u968F agent \u51FA\u5382\uFF0C\u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.empty_or_non_string":"\u89D2\u8272 ID \u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.vp.idError.too_long":"\u89D2\u8272 ID \u592A\u957F\uFF08\u6700\u591A 40 \u5B57\u7B26\uFF09\u3002","yeaft.vp.idError.illegal_character":'\u53EA\u80FD\u4F7F\u7528\u5B57\u6BCD\u3001\u6570\u5B57\u3001"-" \u548C "_"\u3002',"yeaft.vp.idError.underscore_prefix_reserved":'\u89D2\u8272 ID \u4E0D\u80FD\u4EE5 "_" \u5F00\u5934\uFF08\u9884\u7559\u7ED9\u7CFB\u7EDF\u89D2\u8272\uFF09\u3002',"yeaft.vp.idError.pure_digits":"\u89D2\u8272 ID \u4E0D\u80FD\u662F\u7EAF\u6570\u5B57\u3002","yeaft.vp.idError.reserved":"\u89D2\u8272 ID \u4E0D\u80FD\u7528\u4FDD\u7559\u540D\uFF08all / user / system / everyone\uFF09\u3002","yeaft.vp.idError.duplicate":"\u5DF2\u7ECF\u5B58\u5728\u540C ID \u7684\u89D2\u8272\u3002","yeaft.vp.idError.not_found":"\u8BE5 VP \u4E0D\u5B58\u5728\uFF0C\u53EF\u80FD\u5DF2\u88AB\u5220\u9664\u3002","yeaft.vp.idError.stock_readonly":"\u9884\u88C5 VP \u4E0D\u80FD\u7F16\u8F91\u6216\u5220\u9664\u3002","yeaft.vp.idError.unknown":"\u53D1\u751F\u672A\u77E5\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.vp.reason.personaEdit":"\u4EBA\u8BBE\u5DF2\u66F4\u65B0","yeaft.vp.reason.traitsEdit":"\u7279\u5F81\u5DF2\u66F4\u65B0","yeaft.vp.reason.manualReload":"\u5DF2\u91CD\u65B0\u8F7D\u5165","yeaft.vp.reason.fileRemoved":"\u5DF2\u79FB\u9664","yeaft.vp.reason.toast.updated":"{name}\uFF1A{reason}","yeaft.vp.reason.toast.removed":"{name} \u5DF2\u88AB\u79FB\u9664","yeaft.message.timeAria":"\u53D1\u9001\u4E8E {time}","yeaft.user.youLabel":"\u6211","yeaft.session.sidebarTitle":"\u4F1A\u8BDD","yeaft.session.sidebarAria":"\u4F1A\u8BDD\u5217\u8868","yeaft.session.newButton":"+ \u65B0\u5EFA\u4F1A\u8BDD","yeaft.session.newButtonAria":"\u521B\u5EFA\u65B0\u4F1A\u8BDD","yeaft.session.empty":"\u6682\u65E0\u4F1A\u8BDD\u3002","yeaft.session.membersCount":"{count} \u4F4D\u6210\u5458","yeaft.session.oneMember":"1 \u4F4D\u6210\u5458","yeaft.session.noMembers":"\u7A7A\u4F1A\u8BDD \u2014 \u8BF7\u9080\u8BF7 VP","yeaft.session.defaultBadge":"\u9ED8\u8BA4","yeaft.session.defaultName":"\u9ED8\u8BA4\u4F1A\u8BDD","yeaft.session.moreActions":"\u66F4\u591A\u64CD\u4F5C","yeaft.session.archive":"\u5F52\u6863","yeaft.session.archiveConfirm":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.archivingEllipsis":"\u5F52\u6863\u4E2D\u2026","yeaft.session.delete":"\u5220\u9664","yeaft.session.deleteConfirm":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.deletingEllipsis":"\u5220\u9664\u4E2D\u2026","yeaft.session.rename":"\u91CD\u547D\u540D","yeaft.session.openSettings":"\u8BBE\u7F6E","yeaft.session.removeFromList":"\u79FB\u9664","yeaft.session.manageMembers":"\u7BA1\u7406\u6210\u5458","yeaft.session.memberCount.one":"1 \u4F4D\u6210\u5458","yeaft.session.memberCount.other":"{count} \u4F4D\u6210\u5458","yeaft.session.renamePrompt":"\u4E3A\u300C{name}\u300D\u8F93\u5165\u65B0\u540D\u79F0\uFF1A","yeaft.session.renamingEllipsis":"\u91CD\u547D\u540D\u4E2D\u2026","yeaft.session.editModal.renameTitle":"\u91CD\u547D\u540D\u4F1A\u8BDD","yeaft.session.editModal.renameBody":"\u4E3A\u300C{name}\u300D\u9009\u62E9\u4E00\u4E2A\u65B0\u540D\u79F0\u3002","yeaft.session.editModal.renameSubmit":"\u4FDD\u5B58","yeaft.session.editModal.archiveTitle":"\u5F52\u6863\u4F1A\u8BDD","yeaft.session.editModal.archiveBody":"\u5F52\u6863\u300C{name}\u300D\uFF1F\u7A0D\u540E\u53EF\u4ECE\u78C1\u76D8\u6062\u590D\u3002","yeaft.session.editModal.archiveSubmit":"\u5F52\u6863","yeaft.session.editModal.deleteTitle":"\u5220\u9664\u4F1A\u8BDD","yeaft.session.editModal.deleteBody":"\u5220\u9664\u300C{name}\u300D\uFF1F\u5C06\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\u53CA\u5176\u6240\u6709\u6570\u636E\uFF0C\u6B64\u64CD\u4F5C\u4E0D\u53EF\u64A4\u9500\u3002","yeaft.session.editModal.deleteSubmit":"\u5220\u9664","yeaft.session.editModal.newNameLabel":"\u65B0\u540D\u79F0","yeaft.session.editModal.cancel":"\u53D6\u6D88","yeaft.session.editModal.close":"\u5173\u95ED","yeaft.session.error.invalid_name":"\u4F1A\u8BDD\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\u3002","yeaft.session.error.duplicate":"\u8BE5\u4F1A\u8BDD id \u5DF2\u5B58\u5728\u3002","yeaft.session.error.not_found":"\u672A\u627E\u5230\u8BE5\u4F1A\u8BDD\u3002","yeaft.session.error.default_not_in_roster":"\u9ED8\u8BA4 VP \u5FC5\u987B\u5728\u6210\u5458\u5217\u8868\u4E2D\u3002","yeaft.session.error.no_default_vp":"\u8BE5\u4F1A\u8BDD\u6CA1\u6709\u6210\u5458\uFF0C\u8BF7\u4ECE\u89D2\u8272\u5E93\u6DFB\u52A0 VP \u4EE5\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.error.reserved":"\u6240\u9009 id \u4E2D\u5305\u542B\u4FDD\u7559\u540D\uFF08all / user / system / everyone\uFF09\u3002","yeaft.session.error.unknown":"\u4F1A\u8BDD\u64CD\u4F5C\u5931\u8D25\uFF1A{message}","yeaft.session.error.timeout":"\u4F1A\u8BDD\u64CD\u4F5C\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5\u3002","yeaft.session.invite.title":"\u9080\u8BF7 VP","yeaft.session.invite.body":"\u300C{name}\u300D\u5F53\u524D\u4E3A\u7A7A\uFF0C\u8BF7\u4ECE\u89D2\u8272\u5E93\u6DFB\u52A0\u4E00\u4F4D VP \u4EE5\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.invite.openLibrary":"\u6253\u5F00\u89D2\u8272\u5E93","yeaft.session.invite.dismiss":"\u6682\u4E0D","yeaft.session.empty.title":"\u7A7A\u4F1A\u8BDD","yeaft.session.empty.hint":"\u300C{name}\u300D\u8FD8\u6CA1\u6709\u6210\u5458\u3002\u6DFB\u52A0\u4E00\u4F4D VP \u5373\u53EF\u5F00\u59CB\u5BF9\u8BDD\u3002","yeaft.session.empty.cta":"\u7BA1\u7406\u6210\u5458","yeaft.session.members.title":"\u7BA1\u7406\u300C{name}\u300D\u7684\u6210\u5458","yeaft.session.members.aria":"\u6210\u5458\u7BA1\u7406","yeaft.session.members.close":"\u5173\u95ED","yeaft.session.members.done":"\u5B8C\u6210","yeaft.session.members.empty":"\u6682\u65E0\u53EF\u7528 VP \u2014 \u8BF7\u5148\u5230\u89D2\u8272\u5E93\u521B\u5EFA\u3002","yeaft.session.members.loading":"VP \u52A0\u8F7D\u4E2D\u2026","yeaft.session.members.defaultHint":"\u9ED8\u8BA4 VP\uFF08@\u63D0\u53CA\u7F3A\u7701\u65F6\u7531\u8BE5 VP \u5E94\u7B54\uFF09","yeaft.session.members.memberCount":"\u5DF2\u9009 {count} \u4F4D","yeaft.session.members.actionFailed":"\u64CD\u4F5C\u5931\u8D25\uFF1A{error}","yeaft.session.members.openLibrary":"\u6253\u5F00 VP \u5E93","yeaft.session.members.openLibraryHint":"\u5728 VP \u5E93\u53EF\u521B\u5EFA\u65B0 VP \u6216\u67E5\u770B VP \u7684 prompt\u3002","yeaft.session.announcement.label":"\u4F1A\u8BDD\u516C\u544A","yeaft.session.announcement.hintEmpty":"\u6682\u65E0\u516C\u544A \u2014 \u70B9\u51FB \u270F\uFE0F \u6DFB\u52A0\u3002","yeaft.session.announcement.emptyBody":"\u672A\u8BBE\u7F6E\u4F1A\u8BDD\u516C\u544A\u3002\u53EF\u4EE5\u5728\u8FD9\u91CC\u5199\u4E00\u6BB5\u7B80\u4ECB\uFF0C\u4F1A\u8BDD\u5185\u6240\u6709 VP \u5728\u6536\u5230\u6D88\u606F\u65F6\u90FD\u4F1A\u5728 system prompt \u9876\u90E8\u770B\u5230 \u2014 \u9002\u5408\u5199\u5171\u540C\u80CC\u666F\u3001\u89C4\u5219\u3001\u6216 CLAUDE.md \u5F0F\u7684\u6307\u5F15\u3002","yeaft.session.announcement.placeholder":"\u4E3A\u8FD9\u4E2A\u4F1A\u8BDD\u91CC\u7684\u6240\u6709 VP \u5199\u4E00\u6BB5\u5171\u4EAB\u7684\u7B80\u4ECB\u2026","yeaft.session.announcement.edit":"\u7F16\u8F91\u516C\u544A","yeaft.session.announcement.editTitle":"\u7F16\u8F91\u4F1A\u8BDD\u516C\u544A","yeaft.session.announcement.saving":"\u4FDD\u5B58\u4E2D\u2026","yeaft.session.announcement.saveFailed":"\u4FDD\u5B58\u5931\u8D25\uFF1A{error}","yeaft.session.announcement.openSettings":"\u6253\u5F00\u4F1A\u8BDD\u8BBE\u7F6E","yeaft.session.settings.title":"{name} \u2014 \u4F1A\u8BDD\u8BBE\u7F6E","yeaft.session.settings.short":"\u4F1A\u8BDD","yeaft.session.settings.close":"\u5173\u95ED","yeaft.session.settings.nav.session":"\u4F1A\u8BDD","yeaft.session.settings.nav.members":"\u6210\u5458","yeaft.session.settings.nav.memory":"\u4F1A\u8BDD\u8BB0\u5FC6","yeaft.session.settings.announcement.heading":"\u4F1A\u8BDD\u516C\u544A","yeaft.session.settings.announcement.help":"\u6CE8\u5165\u5230\u4F1A\u8BDD\u5185\u6BCF\u4E2A VP \u7684 system prompt \u9876\u90E8 \u2014 \u7C7B\u4F3C\u56E2\u961F\u5171\u4EAB\u7684 CLAUDE.md\u3002","yeaft.session.settings.members.heading":"\u6210\u5458","yeaft.session.settings.rename.heading":"\u91CD\u547D\u540D\u4F1A\u8BDD","yeaft.session.settings.rename.label":"\u65B0\u540D\u79F0","yeaft.session.settings.rename.save":"\u4FDD\u5B58\u540D\u79F0","yeaft.session.settings.rename.saving":"\u4FDD\u5B58\u4E2D\u2026","yeaft.session.settings.memory.heading":"\u4F1A\u8BDD\u8BB0\u5FC6","yeaft.session.settings.memory.help":"\u7ACB\u5373\u8FD0\u884C dream \u6574\u7406\uFF1A\u8BFB\u53D6\u4E0A\u6B21\u4EE5\u6765\u7684\u65B0\u6D88\u606F\uFF0C\u63D0\u53D6\u8981\u70B9\u5E76\u5408\u5E76\u8FDB\u4F1A\u8BDD\u7684 summary\uFF0C\u8BA9 Resident \u5C42\u80FD\u53CD\u6620\u6700\u65B0\u7684\u5BF9\u8BDD\u3002","yeaft.session.settings.memory.runNow":"\u7ACB\u5373\u8FD0\u884C dream","yeaft.session.settings.memory.running":"\u8FD0\u884C\u4E2D\u2026","yeaft.session.settings.memory.lastSuccess":"\u4E0A\u6B21\u6210\u529F\uFF1A{time} \u2014 \u66F4\u65B0\u4E86 {count} \u4E2A\u76EE\u6807\u3002","yeaft.session.settings.memory.lastError":"\u4E0A\u6B21\u8FD0\u884C\u5931\u8D25\uFF1A{error}","yeaft.session.settings.danger.heading":"\u5220\u9664\u4F1A\u8BDD","yeaft.session.settings.danger.deleteHelp":"\u8FD9\u4F1A\u6C38\u4E45\u5220\u9664\u8BE5\u4F1A\u8BDD\uFF0C\u79FB\u9664\u78C1\u76D8\u4E0A\u7684 session.json \u548C\u5168\u90E8\u6D88\u606F\u5386\u53F2\uFF0C\u4E0D\u53EF\u6062\u590D\u3002","yeaft.session.settings.danger.deleteBtn":"\u5220\u9664\u4F1A\u8BDD","yeaft.vp.mention.placeholder":"\u6309 id \u6216\u540D\u79F0\u641C\u7D22\u89D2\u8272\u2026","yeaft.vp.mention.noMatch":"\u6CA1\u6709\u5339\u914D\u7684\u89D2\u8272","yeaft.vp.mention.count":"\u5DF2 @{count} \u4EBA","yeaft.feature.reject.missing_group_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u672A\u6307\u5B9A\u4F1A\u8BDD\u3002","yeaft.feature.reject.missing_feature_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u4EFB\u52A1\u4E0A\u4E0B\u6587\u4E22\u5931\u3002","yeaft.feature.reject.missing_vp_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u672A\u8BBE\u7F6E\u53D1\u8A00\u8005\u3002","yeaft.feature.reject.invalid_vp_id":"\u53D1\u9001\u5931\u8D25\uFF1A\u53D1\u8A00\u8005 id \u975E\u6CD5\u3002","yeaft.feature.reject.empty_text":"\u53D1\u9001\u5931\u8D25\uFF1A\u5185\u5BB9\u4E3A\u7A7A\u3002","yeaft.feature.reject.text_too_long":"\u53D1\u9001\u5931\u8D25\uFF1A\u5185\u5BB9\u8FC7\u957F\uFF08\u4E0A\u9650 16 KiB\uFF09\u3002","yeaft.feature.reject.unknown":"\u53D1\u9001\u5931\u8D25\u3002","yeaft.feature.pill.label":"\u4EFB\u52A1","yeaft.feature.messageTime.aria":"\u53D1\u9001\u4E8E {time}","yeaft.vp.turnBlock.elapsedTitle":"\u672C\u8F6E turn \u5F00\u59CB\u81F3\u4ECA\u7684\u65F6\u95F4","yeaft.vp.turnBlock.retryingRequest":"\u54CD\u5E94\u505C\u6EDE\uFF0C\u6B63\u5728\u53D1\u8D77\u5168\u65B0\u8BF7\u6C42\uFF08{attempt}/{max}\uFF09","yeaft.vp.turnBlock.retryingContinue":"\u54CD\u5E94\u505C\u6EDE\uFF0C\u6B63\u5728\u7528\u5168\u65B0\u8BF7\u6C42\u7EED\u5199\uFF08{attempt}/{max}\uFF09","yeaft.sessionStatus.aria":"Session \u72B6\u6001","yeaft.sessionStatus.title":"Session \u72B6\u6001","yeaft.sessionStatus.announcement":"\u516C\u544A","yeaft.sessionStatus.announcementEmpty":"\u6682\u65E0\u516C\u544A","yeaft.sessionStatus.announcementAdd":"\u6DFB\u52A0\u516C\u544A","yeaft.sessionStatus.announcementEdit":"\u7F16\u8F91\u516C\u544A","yeaft.sessionStatus.vps":"VP","yeaft.sessionStatus.backgroundTasks":"\u540E\u53F0\u4EFB\u52A1","yeaft.sessionStatus.noLogPreview":"\u6682\u65E0\u65E5\u5FD7\u8F93\u51FA\u3002","yeaft.sessionStatus.task.subAgentStarted":"{name} \u5DF2\u542F\u52A8","yeaft.sessionStatus.task.subAgentStartedWithMission":"{name} \u5DF2\u542F\u52A8\uFF1A{mission}","yeaft.sessionStatus.task.subAgentStatus":"{name} \u72B6\u6001\uFF1A{status}","yeaft.sessionStatus.task.subAgentStatusUpdated":"{name} \u72B6\u6001\u5DF2\u66F4\u65B0","yeaft.sessionStatus.task.subAgentResult":"{name} \u7ED3\u679C\uFF1A{text}","yeaft.sessionStatus.task.subAgentProducedResult":"{name} \u5DF2\u4EA7\u751F\u7ED3\u679C","yeaft.sessionStatus.task.subAgentUsedTool":"{name} \u8C03\u7528\u4E86 {tool}","yeaft.sessionStatus.task.subAgentFinishedTool":"{name} \u5B8C\u6210\u4E86 {tool}","yeaft.sessionStatus.task.subAgentUsage":"{name} \u4F7F\u7528\u4E86 {tokens} tokens","yeaft.sessionStatus.task.subAgentEvent":"{name}\uFF1A{text}","yeaft.sessionStatus.task.subAgentUserPrompt":"\u4F60\uFF1A{text}","yeaft.sessionStatus.task.subAgentToolSummary":"\u5DF2\u5B8C\u6210 {count} \u6B21\u5DE5\u5177\u8C03\u7528","yeaft.sessionStatus.task.subAgentError":"{name} \u9519\u8BEF\uFF1A{error}","yeaft.sessionStatus.task.subAgentHitError":"{name} \u9047\u5230\u9519\u8BEF","yeaft.sessionStatus.task.subAgentNoReadableEvents":"\u6682\u65E0\u53EF\u8BFB\u7684 sub-agent \u6D3B\u52A8\u3002","yeaft.sessionStatus.task.promptPlaceholder":"\u7ED9\u8FD9\u4E2A sub-agent \u8FFD\u52A0\u60F3\u6CD5\u2026","yeaft.sessionStatus.task.promptSend":"\u53D1\u9001","yeaft.sessionStatus.task.promptSending":"\u53D1\u9001\u4E2D\u2026","yeaft.sessionStatus.task.promptFailed":"\u53D1\u9001\u5931\u8D25\u3002","yeaft.sessionStatus.task.title":"\u4EFB\u52A1","yeaft.sessionStatus.task.command":"\u547D\u4EE4","yeaft.sessionStatus.task.stop":"\u505C\u6B62\u4EFB\u52A1","yeaft.sessionStatus.task.stopping":"\u505C\u6B62\u4E2D\u2026","yeaft.sessionStatus.task.kind.subAgent":"sub-agent","yeaft.sessionStatus.task.kind.shell":"shell","yeaft.sessionStatus.show":"\u663E\u793A Session \u72B6\u6001","yeaft.sessionStatus.hide":"\u9690\u85CF Session \u72B6\u6001","yeaft.sessionStatus.close":"\u5173\u95ED Session \u72B6\u6001","yeaft.vpTimeline.empty":"\u672C Session \u8FD8\u6CA1\u6709 VP\u3002","yeaft.vpTimeline.resizeTitle":"\u62D6\u52A8\u8C03\u6574\u5BBD\u5EA6","yeaft.vpTimeline.status.idle":"\u7A7A\u95F2","yeaft.vpTimeline.status.typing":"\u8F93\u5165\u4E2D\u2026","yeaft.vpTimeline.status.thinking":"\u601D\u8003\u4E2D\u2026","yeaft.vpTimeline.status.retrying":"\u6B63\u5728\u91CD\u8BD5\u8BF7\u6C42\u2026","yeaft.vpTimeline.status.streaming":"\u751F\u6210\u4E2D","yeaft.vpTimeline.status.tool":"\u8C03\u7528\u5DE5\u5177\u4E2D\u2026","yeaft.vpTimeline.status.error":"\u51FA\u9519","yeaft.vpTimeline.status.offline":"\u79BB\u7EBF","yeaft.vpTimeline.abort":"\u4E2D\u6B62","yeaft.vpTimeline.edit":"\u7F16\u8F91 VP","yeaft.vpTimeline.mention":"\u70B9\u51FB @ \u8BE5 VP","yeaft.vpTimeline.expand":"\u5C55\u5F00\u4EFB\u52A1\u8BE6\u60C5","yeaft.toolStats.title":"\u5DE5\u5177\u4F7F\u7528\u7EDF\u8BA1","yeaft.toolStats.refresh":"\u5237\u65B0","yeaft.toolStats.close":"\u5173\u95ED","yeaft.toolStats.tabAll":"\u5168\u90E8\u5DE5\u5177","yeaft.toolStats.tabUnused":"\u672A\u4F7F\u7528","yeaft.toolStats.loading":"\u52A0\u8F7D\u4E2D\u2026","yeaft.toolStats.notLoaded":"\u6682\u65E0\u6570\u636E \u2014 \u70B9\u51FB\u5237\u65B0\u3002","yeaft.toolStats.empty":"\uFF08\u6682\u65E0\u5DE5\u5177\u8C03\u7528\u8BB0\u5F55\uFF09","yeaft.toolStats.noneUnused":"\uFF08\u6BCF\u4E2A\u5DF2\u6CE8\u518C\u5DE5\u5177\u90FD\u81F3\u5C11\u88AB\u8C03\u7528\u8FC7\u4E00\u6B21\uFF09","yeaft.toolStats.fetchedAt":"\u83B7\u53D6\u65F6\u95F4","yeaft.toolStats.col.name":"\u5DE5\u5177","yeaft.toolStats.col.calls":"\u8C03\u7528","yeaft.toolStats.col.errors":"\u9519\u8BEF","yeaft.toolStats.col.errRate":"\u9519\u8BEF\u7387","yeaft.toolStats.col.p50":"p50","yeaft.toolStats.col.p95":"p95","yeaft.toolStats.col.avg":"\u5E73\u5747","yeaft.toolStats.col.last":"\u6700\u8FD1","yeaft.toolStats.buttonLabel":"\u5DE5\u5177\u7EDF\u8BA1","workCenter.title":"\u5DE5\u4F5C\u4E2D\u5FC3","workCenter.subtitle":"\u7531\u5F53\u524D Agent \u6301\u7EED\u63A8\u8FDB\u7684\u6301\u4E45\u5DE5\u4F5C","workCenter.agent":"Agent","workCenter.selectAgent":"\u9009\u62E9 Agent","workCenter.noOnlineAgents":"\u6CA1\u6709\u5728\u7EBF Agent","workCenter.noAvailableAgents":"\u6CA1\u6709\u517C\u5BB9\u5DE5\u4F5C\u4E2D\u5FC3\u7684\u5728\u7EBF Agent","workCenter.new":"\u65B0\u5EFA","workCenter.newWorkItem":"\u65B0\u5EFA\u5DE5\u4F5C\u9879","workCenter.workItem":"\u5DE5\u4F5C\u9879","workCenter.createFirst":"\u521B\u5EFA\u7B2C\u4E00\u4E2A\u5DE5\u4F5C\u9879","workCenter.backToChat":"\u8FD4\u56DE\u5BF9\u8BDD","workCenter.refresh":"\u5237\u65B0","workCenter.search":"\u641C\u7D22\u5DE5\u4F5C\u9879","workCenter.filter":"\u7B5B\u9009","workCenter.filterAttention":"\u9700\u8981\u5904\u7406","workCenter.filterActive":"\u6267\u884C\u4E2D","workCenter.filterAll":"\u5168\u90E8","workCenter.filterDone":"\u5DF2\u5B8C\u6210","workCenter.attentionItems":"\u9700\u8981\u5904\u7406","workCenter.board.active":"\u8FDB\u884C\u4E2D","workCenter.board.needsAttention":"\u9700\u8981\u5904\u7406","workCenter.board.closed":"\u5DF2\u5173\u95ED","workCenter.board.emptyLane":"\u6682\u65E0\u5DE5\u4F5C\u9879","workCenter.board.lanes":"\u5DE5\u4F5C\u9879\u5206\u680F","workCenter.filterVp":"\u6309 VP \u7B5B\u9009","workCenter.filterType":"\u6309\u7C7B\u578B\u7B5B\u9009","workCenter.filterUpdated":"\u6309\u66F4\u65B0\u65F6\u95F4\u7B5B\u9009","workCenter.allVps":"\u5168\u90E8 VP","workCenter.allTypes":"\u5168\u90E8\u7C7B\u578B","workCenter.anyTime":"\u4E0D\u9650\u65F6\u95F4","workCenter.lastDay":"\u6700\u8FD1 24 \u5C0F\u65F6","workCenter.lastWeek":"\u6700\u8FD1 7 \u5929","workCenter.deleteWorkItem":"\u5220\u9664 Work Item","workCenter.deleteConfirm":"\u6C38\u4E45\u5220\u9664\u8FD9\u4E2A Work Item\u3001\u6267\u884C\u5386\u53F2\u548C\u9644\u4EF6\uFF1F","workCenter.deleteRequiresStop":"\u8BF7\u5148\u505C\u6B62\u8FD9\u4E2A Work Item \u518D\u5220\u9664","workCenter.lastMonth":"\u6700\u8FD1 30 \u5929","workCenter.assignment.planned":"\u8BA1\u5212\u5206\u914D","workCenter.created":"\u521B\u5EFA\u4E8E","workCenter.files":"\u4E2A\u6587\u4EF6","workCenter.loadMore":"\u52A0\u8F7D\u66F4\u591A","workCenter.activeItems":"\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C","workCenter.allItems":"\u5168\u90E8\u5DE5\u4F5C\u9879","workCenter.completedItems":"\u5DF2\u5B8C\u6210","workCenter.watcherActive":"Watcher \u8FD0\u884C\u4E2D","workCenter.loading":"\u6B63\u5728\u52A0\u8F7D\u5DE5\u4F5C\u9879\u2026","workCenter.noTimestamp":"\u65E0\u65F6\u95F4\u6233","workCenter.updated":"\u66F4\u65B0\u65F6\u95F4","workCenter.emptyTitle":"\u8FD8\u6CA1\u6709\u5DE5\u4F5C\u9879","workCenter.emptyBody":"\u5F53\u5DE5\u4F5C\u9700\u8981\u8DE8\u8D8A\u4E00\u6B21\u5BF9\u8BDD\u3001\u7B49\u5F85\u6216\u89D2\u8272\u63A5\u529B\u65F6\uFF0C\u628A\u5B83\u521B\u5EFA\u4E3A\u6301\u4E45\u5DE5\u4F5C\u9879\u3002","workCenter.noAttentionTitle":"\u5F53\u524D\u6CA1\u6709\u9700\u8981\u5904\u7406\u7684\u5DE5\u4F5C\u9879","workCenter.noAttentionBody":"\u7B49\u5F85\u4F60\u56DE\u7B54\u6216\u9700\u8981\u6062\u590D\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noActiveTitle":"\u5F53\u524D\u6CA1\u6709\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C\u9879","workCenter.noActiveBody":"\u8349\u7A3F\u3001\u5C31\u7EEA\u548C\u6267\u884C\u4E2D\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noCompletedTitle":"\u8FD8\u6CA1\u6709\u5DF2\u5B8C\u6210\u7684\u5DE5\u4F5C\u9879","workCenter.noCompletedBody":"\u5B8C\u6210\u540E\u7684\u5DE5\u4F5C\u9879\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\u3002","workCenter.noMatchesTitle":"\u6CA1\u6709\u5339\u914D\u7684\u5DE5\u4F5C\u9879","workCenter.noMatchesBody":"\u5C1D\u8BD5\u8C03\u6574\u641C\u7D22\u5185\u5BB9\u6216\u7B5B\u9009\u6761\u4EF6\u3002","workCenter.selectTitle":"\u5DE5\u4F5C\u9879\u8BE6\u60C5","workCenter.detailLoading":"\u6B63\u5728\u52A0\u8F7D\u5B8C\u6574\u8BE6\u60C5\u2026","workCenter.detailLoadFailed":"\u65E0\u6CD5\u52A0\u8F7D\u5B8C\u6574\u8BE6\u60C5","workCenter.start":"\u5F00\u59CB","workCenter.retry":"\u91CD\u8BD5","workCenter.cancel":"\u53D6\u6D88","workCenter.closeWorkItem":"\u5173\u95ED\u8BE6\u60C5","workCenter.cancelWorkItem":"\u505C\u6B62\u5DE5\u4F5C\u9879","workCenter.cancelWorkItemHint":"\u505C\u6B62\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53CA\u6240\u6709\u5C1A\u672A\u5B8C\u6210\u7684 Actions\u3002","workCenter.cancelConfirm":"\u505C\u6B62\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53CA\u5176\u5C1A\u672A\u5B8C\u6210\u7684 Actions\uFF1F","workCenter.stopWorkItem":"\u505C\u6B62\u5DE5\u4F5C\u9879","workCenter.resumeWorkItem":"\u6062\u590D\u5DE5\u4F5C\u9879","workCenter.breadcrumbs":"Work Center \u5BFC\u822A","workCenter.actionNumber":"Action {number}","workCenter.actionBreadcrumb":"Action {number}\uFF1A{description}","workCenter.untitledAction":"\u672A\u547D\u540D Action","workCenter.workItems":"\u5DE5\u4F5C\u9879","workCenter.description":"\u9700\u6C42\u63CF\u8FF0","workCenter.goal":"\u76EE\u6807","workCenter.acceptanceCriteria":"\u9A8C\u6536\u6761\u4EF6","workCenter.noCriteria":"\u672A\u63D0\u4F9B\u9A8C\u6536\u6761\u4EF6","workCenter.failureReason":"\u5931\u8D25\u539F\u56E0","workCenter.workflow":"\u4EFB\u52A1\u6D41","workCenter.actionFlow":"Action \u6D41\u7A0B","workCenter.actionCount":"{count} \u4E2A Action","workCenter.noActionSummary":"\u6682\u65E0\u6458\u8981","workCenter.actionProgress":"{completed} / {total} \u4E2A Action","workCenter.currentAction":"\u5F53\u524D Action","workCenter.expandActions":"\u5C55\u5F00 Action","workCenter.collapseActions":"\u6536\u8D77","workCenter.actionObjective":"\u8FD9\u6B21\u8981\u505A\u4EC0\u4E48","workCenter.actionApproach":"\u51C6\u5907\u600E\u4E48\u505A","workCenter.actionExpectedOutcome":"\u671F\u5F85\u7684\u7ED3\u679C","workCenter.dependencies":"\u4F9D\u8D56\u9879","workCenter.actionResult":"\u6700\u65B0\u7ED3\u679C","workCenter.currentProgress":"\u5F53\u524D\u8FDB\u5EA6","workCenter.actionMessages":"\u6D88\u606F","workCenter.loops":"\u4E2A Loop","workCenter.tools":"\u6B21\u5DE5\u5177\u8C03\u7528","workCenter.noActionMessages":"\u8FD8\u6CA1\u6709\u6D88\u606F\u3002","workCenter.actionDetails":"Action \u8BE6\u60C5","workCenter.selectAction":"\u9009\u62E9\u4E00\u4E2A Action \u67E5\u770B\u5B9E\u9645\u6267\u884C","workCenter.backToWorkItems":"\u5DE5\u4F5C\u9879","workCenter.backToActions":"\u8FD4\u56DE Actions","workCenter.you":"\u4F60","workCenter.noRequestDetails":"\u8FD9\u4E2A Action \u6682\u65F6\u6CA1\u6709\u53EF\u7528\u7684\u6267\u884C\u8BB0\u5F55\u3002","workCenter.loadingRequests":"\u6B63\u5728\u52A0\u8F7D\u6267\u884C\u8BB0\u5F55\u2026","workCenter.loadingRequestDetail":"\u6B63\u5728\u52A0\u8F7D\u5DE5\u5177\u8BC1\u636E\u2026","workCenter.requestDetailUnavailable":"\u5DE5\u5177\u8BC1\u636E\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.noRequestLoops":"\u8FD9\u6B21\u6267\u884C\u6CA1\u6709\u4FDD\u7559\u4E0B\u53EF\u5C55\u793A\u7684 Loop\u3002","workCenter.requestDetailTruncated":"\u6267\u884C\u5185\u5BB9\u8F83\u5927\uFF1A{summarized} \u4E2A Loop \u663E\u793A\u6458\u8981\uFF0C\u53E6\u6709 {omitted} \u4E2A\u8F83\u65E9 Loop \u672A\u663E\u793A\u3002","workCenter.loopDetailTruncated":"\u8FD9\u4E2A Loop \u5185\u5BB9\u8F83\u5927\uFF0C\u5F53\u524D\u663E\u793A\u4FDD\u7559\u4E0B\u6765\u7684\u5DE5\u5177\u8BC1\u636E\u3002","workCenter.loadEarlierMessages":"\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F","workCenter.loadingEarlierMessages":"\u6B63\u5728\u52A0\u8F7D\u66F4\u65E9\u6D88\u606F\u2026","workCenter.unknownModel":"\u672A\u77E5\u6A21\u578B","workCenter.loop":"Loop","workCenter.actionBrief":"\u4EFB\u52A1\u8BF4\u660E","workCenter.executionSummary":"\u6267\u884C\u6458\u8981","workCenter.toolParameters":"\u8C03\u7528\u53C2\u6570","workCenter.toolResult":"\u6267\u884C\u7ED3\u679C","workCenter.noToolCalls":"\u8FD9\u4E2A Loop \u6CA1\u6709\u5DE5\u5177\u8C03\u7528\u3002","workCenter.actionInputPlaceholder":"\u8865\u5145\u4E0A\u4E0B\u6587\u3001\u56DE\u7B54\u95EE\u9898\u6216\u8C03\u6574\u8FD9\u4E2A Action","workCenter.actionInputResumeHint":"\u4F60\u7684\u8F93\u5165\u4F1A\u5E26\u7740\u65B0\u589E\u4E0A\u4E0B\u6587\u7EE7\u7EED\u8FD9\u4E2A Action\u3002","workCenter.waitingQuestionTitle":"\u9700\u8981\u4F60\u7684\u56DE\u7B54","workCenter.actionInputRetryHint":"\u8865\u5145\u4FEE\u6B63\u8BF4\u660E\u6216\u6587\u4EF6\u540E\uFF0C\u4F7F\u7528\u65B0\u4E0A\u4E0B\u6587\u91CD\u65B0\u6267\u884C\u8FD9\u4E2A Action\u3002","workCenter.actionInputContinueHint":"\u8FD9\u91CC\u53EA\u76F4\u63A5\u5E72\u9884\u5F53\u524D Action\u3002","workCenter.actionFailedTitle":"\u8FD9\u4E2A Action \u4E3A\u4EC0\u4E48\u5931\u8D25","workCenter.failedAt":"\u5931\u8D25\u65F6\u95F4","workCenter.actionFailureRecovery":"\u5728\u5DE6\u4FA7\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u5C06\u76EE\u6807\u8BBE\u4E3A\u6B64 Action\uFF0C\u518D\u53D1\u9001\u4FEE\u6B63\u8BF4\u660E\uFF1B\u6267\u884C\u89C6\u56FE\u4F1A\u5C55\u793A\u4FDD\u7559\u4E0B\u6765\u7684\u5DE5\u5177\u8BC1\u636E\u3002","workCenter.sendInput":"\u53D1\u9001\u7ED9 Action","workCenter.sendingInput":"\u6B63\u5728\u53D1\u9001\u2026","workCenter.retryAction":"\u91CD\u8BD5 Action","workCenter.sendAndRetryAction":"\u53D1\u9001\u5E76\u91CD\u8BD5 Action","workCenter.coordinatorDecision.guide_actions":"\u5DF2\u66F4\u65B0 Action \u6307\u4EE4","workCenter.coordinatorDecision.replan":"\u5DF2\u66F4\u65B0\u76EE\u6807\u6216\u8BA1\u5212","workCenter.coordinatorDecision.request_human":"\u9700\u8981\u4EBA\u5DE5\u8865\u5145\u4FE1\u606F","workCenter.conversation":"\u5BF9\u8BDD","workCenter.contentPane":"\u5185\u5BB9","workCenter.workItemPanes":"\u5DE5\u4F5C\u9879\u9762\u677F","workCenter.coordinator":"\u534F\u8C03\u8005","workCenter.sendTo":"\u53D1\u9001\u7ED9","workCenter.composerTarget":"\u6D88\u606F\u76EE\u6807","workCenter.targetUnavailable":"\u6240\u9009 Action \u5DF2\u4E0D\u53EF\u7528","workCenter.targetUnavailableHelp":"\u53D1\u9001\u524D\u8BF7\u9009\u62E9\u5176\u4ED6\u76EE\u6807\uFF1B\u7CFB\u7EDF\u6CA1\u6709\u91CD\u5B9A\u5411\u8FD9\u4EFD\u8349\u7A3F\u3002","workCenter.sendToCoordinatorInstead":"\u6539\u53D1\u7ED9 Coordinator","workCenter.composerTargetAction":"Action {sequence}\uFF1A{name}","workCenter.sendToTarget":"\u53D1\u9001\u7ED9 {target}","workCenter.targetThisAction":"\u53D1\u9001\u7ED9\u6B64 Action","workCenter.answerWithTarget":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u9009\u62E9\u76F8\u5173\u76EE\u6807\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.conversationThinking":"\u5904\u7406\u4E2D\u2026","workCenter.conversationReadOnly":"\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u5DF2\u5173\u95ED\uFF0C\u5BF9\u8BDD\u8BB0\u5F55\u4ECD\u53EF\u67E5\u770B\u3002","workCenter.conversationPlaceholder":"\u7EE7\u7EED\u8BA8\u8BBA\u8FD9\u4E2A\u5DE5\u4F5C\u9879","workCenter.sendMessage":"\u53D1\u9001\u6D88\u606F","workCenter.assistant":"Yeaft","workCenter.originalRequest":"\u539F\u59CB\u9700\u6C42","workCenter.actionMessageScopeTitle":"\u7ED9\u8FD9\u4E2A Action \u53D1\u6D88\u606F","workCenter.actionMessageScope":"\u6D88\u606F\u53EA\u53D1\u9001\u7ED9\u5F53\u524D Action\u3002","workCenter.actionConversation":"\u5BF9\u8BDD","workCenter.actionConversationWith":"Action \u6267\u884C\u8005","workCenter.actionViews":"Action \u89C6\u56FE","workCenter.actionExecutor":"\u6267\u884C\u8005","workCenter.actionExecutorPending":"\u7B49\u5F85\u5206\u914D\u6267\u884C\u8005","workCenter.actionInformation":"Action \u4FE1\u606F","workCenter.messageExecutor":"\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.actionChatPlaceholder":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u7ED9 {name} \u53D1\u6D88\u606F","workCenter.statusLabel":"\u72B6\u6001","workCenter.llmRequestsLabel":"LLM \u8BF7\u6C42","workCenter.loopsLabel":"Loops","workCenter.toolsLabel":"\u5DE5\u5177","workCenter.tokensLabel":"Tokens","workCenter.workItemMessagePlaceholder":"\u8865\u5145\u6574\u4E2A Work Item \u7684\u65B9\u5411\u6216\u7EA6\u675F","workCenter.sendWorkItemMessage":"\u53D1\u9001\u7ED9 Work Item","workCenter.fromSession":"\u4ECE\u5F53\u524D Session \u521B\u5EFA\u5DE5\u4F5C\u9879","workCenter.llmRequestCount":"{count} \u6B21 LLM \u8BF7\u6C42","workCenter.loopCount":"{count} \u6B21 Loop","workCenter.toolCount":"{count} \u4E2A\u5DE5\u5177","workCenter.tokenCount":"{count} tokens","workCenter.tokenBreakdown":"\u8F93\u5165 {input} / \u8F93\u51FA {output} / \u7F13\u5B58 {cache}","workCenter.guidance":"\u7ED9\u5F53\u524D Action \u8865\u5145\u63D0\u793A","workCenter.guidanceHint":"\u8865\u5145\u7EA6\u675F\uFF0C\u6216\u8C03\u6574\u5F53\u524D Action \u7684\u6267\u884C\u65B9\u5411","workCenter.guidanceRestartHint":"\u53D1\u9001\u540E\u4F1A\u4F7F\u7528\u65B0\u63D0\u793A\u91CD\u542F\u5F53\u524D Action\u3002","workCenter.sendGuidance":"\u53D1\u9001\u63D0\u793A","workCenter.reuseMemory":"\u4F7F\u7528\u76F8\u5173 Agent memory \u548C\u6B64\u9879\u76EE\u7684\u5DF2\u5B8C\u6210\u5DE5\u4F5C","workCenter.reuseMemoryHelp":"\u5305\u62EC\u53D7 scope \u7EA6\u675F\u7684 Agent memory\uFF0C\u4EE5\u53CA canonical \u9879\u76EE\u76EE\u5F55\u76F8\u540C\u7684\u5DF2\u5B8C\u6210 Work Item \u7ED3\u6784\u5316\u6458\u8981\u548C\u8BC1\u636E\uFF1B\u4E0D\u4F1A\u590D\u7528\u539F\u59CB\u5DE5\u5177\u8F93\u51FA\u3002","workCenter.resumeAnswer":"\u56DE\u7B54\u7B49\u5F85\u4E2D\u7684\u95EE\u9898","workCenter.resumeAnswerHint":"\u63D0\u4F9B\u7EE7\u7EED\u6267\u884C\u6240\u9700\u7684\u4FE1\u606F","workCenter.answerInActionDetail":"\u5728\u5BF9\u8BDD\u8F93\u5165\u6846\u4E2D\u5C06\u76EE\u6807\u8BBE\u4E3A\u5F53\u524D Action\uFF0C\u7136\u540E\u56DE\u590D\u3002","workCenter.selectPrompt":"\u9009\u62E9\u4E00\u4E2A\u5DE5\u4F5C\u9879\uFF0C\u67E5\u770B\u5B83\u7684\u6D41\u7A0B\u3002","workCenter.createHint":"\u63CF\u8FF0\u4F60\u9700\u8981\u4EC0\u4E48\uFF0CTriage \u4F1A\u751F\u6210\u76EE\u6807\u3001\u9A8C\u6536\u6761\u4EF6\u548C Actions\u3002","workCenter.requirement":"\u9700\u6C42","workCenter.requirementHint":"\u7528\u81EA\u7136\u8BED\u8A00\u63CF\u8FF0\u95EE\u9898\u3001\u671F\u671B\u7ED3\u679C\u548C\u5FC5\u8981\u7EA6\u675F","workCenter.requirementHelp":"Triage \u4F1A\u751F\u6210\u6807\u9898\u3001\u76EE\u6807\u3001\u9A8C\u6536\u6761\u4EF6\u3001\u7C7B\u578B\u548C\u6267\u884C\u8BA1\u5212\u3002","workCenter.titleField":"\u6807\u9898","workCenter.titleHint":"\u7B80\u77ED\u3001\u660E\u786E\u5730\u63CF\u8FF0\u9884\u671F\u7ED3\u679C","workCenter.goalHint":"\u8BF4\u660E Agent \u5FC5\u987B\u4EA4\u4ED8\u7684\u6700\u7EC8\u7ED3\u679C","workCenter.criteriaHint":"\u6BCF\u884C\u4E00\u6761\u9A8C\u6536\u6761\u4EF6","workCenter.attachments":"\u9644\u4EF6","workCenter.attachmentsHelp":"\u56FE\u7247\u3001PDF \u548C\u6587\u672C\u6587\u4EF6\u4F1A\u6301\u7EED\u7ED1\u5B9A\u5230\u6B64 Work Item\uFF0C\u5E76\u63D0\u4F9B\u7ED9\u6BCF\u4E2A Action\u3002","workCenter.attachmentsUnsupported":"\u6240\u9009 Agent \u4E0D\u652F\u6301 Work Item \u9644\u4EF6\u3002","workCenter.addAttachments":"\u6DFB\u52A0\u6587\u4EF6","workCenter.attachmentsUploading":"\u4E0A\u4F20\u4E2D\u2026","workCenter.attachmentsUploadFailed":"\u9644\u4EF6\u4E0A\u4F20\u5931\u8D25","workCenter.pendingEnvelopeLocked":"\u6709\u4E00\u6761\u672A\u786E\u8BA4\u8BF7\u6C42\u5DF2\u9501\u5B9A\u5230\u539F\u59CB\u8EAB\u4EFD\u3002","workCenter.replacePendingAttachments":"\u66FF\u6362\u9644\u4EF6","workCenter.discardPendingEnvelope":"\u653E\u5F03\u5F85\u786E\u8BA4\u8BF7\u6C42","workCenter.pendingEnvelopeChanged":"\u5F85\u786E\u8BA4\u8BF7\u6C42\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u6253\u5F00\u8BE5\u5DE5\u4F5C\u9879\u540E\u518D\u8BD5\u3002","workCenter.removeAttachment":"\u4ECE\u8349\u7A3F\u4E2D\u79FB\u9664","workCenter.previewAttachment":"\u6253\u5F00\u9644\u4EF6","workCenter.openAttachmentNamed":"\u6253\u5F00\u9644\u4EF6 {name}","workCenter.openingAttachment":"\u6B63\u5728\u6253\u5F00\u9644\u4EF6\u2026","workCenter.attachmentPreviewFailed":"\u65E0\u6CD5\u6253\u5F00\u9644\u4EF6\uFF0C\u8BF7\u91CD\u8BD5\u3002","workCenter.attachmentOpenBlocked":"\u6D4F\u89C8\u5668\u963B\u6B62\u4E86\u9644\u4EF6\u7A97\u53E3\uFF0C\u8BF7\u5141\u8BB8\u5F39\u51FA\u7A97\u53E3\u540E\u91CD\u8BD5\u3002","workCenter.execution":"\u6267\u884C\u65B9\u5F0F","workCenter.executionHint":"\u9009\u62E9\u5DE5\u4F5C\u9879\u5728\u54EA\u91CC\u6267\u884C\uFF0C\u4EE5\u53CA\u521B\u5EFA\u540E\u662F\u5426\u7ACB\u5373\u5F00\u59CB\u3002","workCenter.workDir":"\u5DE5\u4F5C\u76EE\u5F55","workCenter.workDirHint":"\u9009\u62E9\u4E00\u4E2A\u5DF2\u5B58\u5728\u7684\u9879\u76EE\u76EE\u5F55","workCenter.chooseFolder":"\u9009\u62E9\u6587\u4EF6\u5939","workCenter.workDirPickerHelp":"\u4ECE\u5F53\u524D Agent \u7684\u771F\u5B9E\u76EE\u5F55\u4E2D\u9009\u62E9\u5DF2\u5B58\u5728\u7684\u6587\u4EF6\u5939\u3002","workCenter.folderPickerHint":"\u9009\u62E9\u8FD9\u4E2A\u5DE5\u4F5C\u9879\u53EF\u4EE5\u8BFB\u53D6\u548C\u4FEE\u6539\u7684\u9879\u76EE\u76EE\u5F55\u3002","workCenter.folderPickerSelectionHint":"\u53CC\u51FB\u8FDB\u5165\u76EE\u5F55\uFF0C\u6216\u9009\u4E2D\u76EE\u5F55\u540E\u786E\u8BA4\u3002","workCenter.startImmediately":"\u7ACB\u5373\u5F00\u59CB","workCenter.startImmediatelyHint":"\u5173\u95ED\u540E\u5C06\u521B\u5EFA\u4E3A\u8349\u7A3F\uFF0C\u786E\u8BA4\u65E0\u8BEF\u540E\u518D\u5F00\u59CB\u3002","workCenter.creating":"\u521B\u5EFA\u4E2D\u2026","workCenter.create":"\u521B\u5EFA","workCenter.status.draft":"\u8349\u7A3F","workCenter.status.ready":"\u5F85\u6267\u884C","workCenter.status.running":"\u6267\u884C\u4E2D","workCenter.status.waiting":"\u7B49\u5F85\u4E2D","workCenter.status.needs_attention":"\u9700\u8981\u5904\u7406","workCenter.status.done":"\u5DF2\u5B8C\u6210","workCenter.status.cancelled":"\u5DF2\u53D6\u6D88","workCenter.status.completed":"\u5DF2\u5B8C\u6210","workCenter.status.failed":"\u5931\u8D25","workCenter.status.superseded":"\u5DF2\u66FF\u4EE3","workCenter.action.triage":"\u5206\u6790","workCenter.action.implement":"\u5B9E\u73B0","workCenter.action.review":"\u8BC4\u5BA1","workCenter.action.integrate":"\u96C6\u6210","workCenter.action.deliver":"\u4EA4\u4ED8","workCenter.action.test":"\u6D4B\u8BD5","workCenter.action.research":"\u7814\u7A76","workCenter.action.design":"\u8BBE\u8BA1","workCenter.action.diagnose":"\u8BCA\u65AD","workCenter.action.migrate":"\u8FC1\u79FB","workCenter.action.document":"\u6587\u6863","workCenter.action.operate":"\u8FD0\u7EF4","workCenter.action.write":"\u5199\u4F5C","workCenter.action.custom":"\u81EA\u5B9A\u4E49","workCenter.assignment.auto":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u7B56\u7565","workCenter.model.inherit":"\u4F7F\u7528\u4EFB\u52A1\u6D41\u6A21\u578B","workCenter.model.defaultProvider":"\u9ED8\u8BA4 Provider","workCenter.planPreview":"\u6267\u884C\u8BA1\u5212","workCenter.planPreviewHelp":"\u6839\u636E\u5F53\u524D Agent \u7684 VP \u6C60\u548C\u6A21\u578B\u8BBE\u7F6E\u5B9E\u65F6\u89E3\u6790\u3002","workCenter.settings.title":"\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E","workCenter.settings.subtitle":"\u914D\u7F6E Coordinator\uFF0C\u4EE5\u53CA AI \u52A8\u6001\u89C4\u5212\u4F7F\u7528\u7684 Action \u63D0\u793A\u8BCD\u3001\u6A21\u578B\u548C effort\u3002","workCenter.settings.workflow":"\u4EFB\u52A1\u6D41","workCenter.settings.workflowHelp":"Triage \u4F1A\u9488\u5BF9\u4EFB\u52A1\u52A8\u6001\u9009\u62E9 Action \u548C\u6267\u884C\u8005\u3002","workCenter.settings.aiWorkflowHelp":"Triage \u4F1A\u4E3A\u6BCF\u4E2A Work Item \u5206\u7C7B\u5E76\u751F\u6210\u7ECF\u8FC7\u6821\u9A8C\u7684 1\u20138 \u4E2A\u4EFB\u52A1\u4E13\u5C5E Action\u3002\u5185\u7F6E Action \u7B56\u7565\u53EA\u662F\u53EF\u590D\u7528\u9ED8\u8BA4\u503C\uFF1B\u9700\u8981\u65F6 triage \u53EF\u4EE5\u521B\u5EFA\u7CBE\u786E\u7684\u9886\u57DF\u7C7B\u578B\u3002","workCenter.settings.globalInstructions":"Agent \u5168\u5C40\u6307\u4EE4","workCenter.settings.globalInstructionsHint":"\u4F8B\u5982\uFF1A\u9075\u5FAA\u4ED3\u5E93\u53D1\u5E03\u6D41\u7A0B\u3001\u5FC5\u987B\u72EC\u7ACB\u8BC4\u5BA1\uFF0C\u672A\u7ECF\u660E\u786E\u6279\u51C6\u4E0D\u5F97\u521B\u5EFA\u90E8\u7F72 tag\u3002","workCenter.settings.globalInstructionsHelp":"\u4FDD\u5B58\u5728 Agent \u7EA7\uFF0C\u5E76\u51BB\u7ED3\u8FDB\u6BCF\u4E2A\u65B0 Work Item\uFF1B\u5BF9 triage \u548C\u6240\u6709\u751F\u6210\u7684 Action \u751F\u6548\uFF0C\u4F18\u5148\u7EA7\u4F4E\u4E8E Work Item \u5951\u7EA6\u53CA\u7CFB\u7EDF/\u5DE5\u5177\u5B89\u5168\u89C4\u5219\u3002\u5DF2\u6709 Work Item \u4FDD\u7559\u539F\u5FEB\u7167\u3002","workCenter.settings.actionPolicies":"\u5185\u7F6E Action \u7B56\u7565","workCenter.settings.actionPoliciesHelp":"\u8FD9\u4E9B\u662F\u53EF\u590D\u7528\u7684\u6267\u884C\u57FA\u7EBF\uFF0C\u4E0D\u662F\u56FA\u5B9A\u5DE5\u4F5C\u6D41\u3002\u672A\u77E5\u7684\u9886\u57DF Action \u7C7B\u578B\u4F1A\u4F7F\u7528\u201C\u81EA\u5B9A\u4E49\u201D\u7B56\u7565\uFF0C\u5E76\u4FDD\u7559 triage \u751F\u6210\u7684\u7C7B\u578B\u548C\u4EFB\u52A1\u76EE\u6807\u3002","workCenter.settings.dynamicInstructionHelp":"AI \u4F1A\u52A0\u5165 Work Item \u5951\u7EA6\u3001\u5168\u5C40\u6307\u4EE4\u3001\u524D\u5E8F Action \u4E0A\u4E0B\u6587\u3001memory \u548C\u4EFB\u52A1\u4E13\u5C5E\u76EE\u6807\uFF1B\u8FD9\u91CC\u5B9A\u4E49\u8BE5 Action \u7C7B\u578B\u7684\u53EF\u590D\u7528\u884C\u4E3A\u3002","workCenter.settings.models":"\u6A21\u578B","workCenter.settings.modelsHelp":"Provider \u548C\u51ED\u8BC1\u4ECD\u7531 Agent LLM \u8BBE\u7F6E\u7BA1\u7406\uFF1B\u5DE5\u4F5C\u4E2D\u5FC3\u53EA\u9009\u62E9\u53EF\u7528\u6A21\u578B\u3002","workCenter.settings.dynamicModelsHelp":"Coordinator \u4E0E\u5B9E\u9645\u6267\u884C Action \u7684\u6A21\u578B\u53EF\u4EE5\u5206\u522B\u914D\u7F6E\u3002","workCenter.settings.coordinatorModel":"Coordinator","workCenter.settings.coordinatorModelHelp":"\u7528\u4E8E Work Item \u5BF9\u8BDD\u3001\u4FEE\u6539\u76EE\u6807\u548C\u91CD\u65B0\u89C4\u5212\uFF1B\u4E0D\u4F1A\u6267\u884C\u9879\u76EE\u5DE5\u5177\u3002","workCenter.settings.allActions":"\u6240\u6709 Action \u7684\u515C\u5E95\u7B56\u7565","workCenter.settings.maxConcurrentActions":"\u6700\u5927\u5E76\u53D1 Action \u6570","workCenter.settings.maxConcurrentActionsHelp":"\u9ED8\u8BA4 3\u3002\u975E Git\u3001\u810F\u5DE5\u4F5C\u533A\u3001\u5171\u4EAB\u526F\u4F5C\u7528\u548C\u96C6\u6210 Action \u4ECD\u4F1A\u4E32\u884C\u6267\u884C\u3002","workCenter.workItemType":"\u7C7B\u578B","workCenter.typeAuto":"Auto \u2014 \u7531 LLM \u63A8\u65AD","workCenter.typeHelp":"\u53EF\u9009\u62E9\u4EFB\u52A1\u7C7B\u522B\uFF0C\u4E5F\u53EF\u8BA9 AI \u81EA\u52A8\u63A8\u65AD\uFF1B\u5177\u4F53 Actions \u59CB\u7EC8\u7531 AI \u89C4\u5212\u3002","workCenter.planning":"\u89C4\u5212\u4E2D","workCenter.aiPlan":"AI \u52A8\u6001\u89C4\u5212\u6267\u884C","workCenter.aiPlanHelp":"Triage \u4F1A\u9009\u62E9\u4EFB\u52A1\u7C7B\u578B\u3001Action\u3001\u6267\u884C\u8005\u548C\u6700\u5C0F\u53EF\u9760\u6D41\u7A0B\uFF1B\u6A21\u578B\u4E0E effort \u7531 Work Center \u8BBE\u7F6E\u63A7\u5236\u3002","workCenter.settings.manageProviders":"\u7BA1\u7406 Agent \u6A21\u578B","workCenter.settings.assignment":"VP \u9009\u62E9","workCenter.settings.assignment.auto":"\u4ECE\u5168\u90E8 VP \u81EA\u52A8\u9009\u62E9","workCenter.settings.assignment.pool":"\u5019\u9009\u6C60","workCenter.settings.assignment.fixed":"\u56FA\u5B9A VP","workCenter.settings.capability":"\u6240\u9700\u80FD\u529B","workCenter.settings.vp":"Virtual Person","workCenter.settings.poolMembers":"\u5019\u9009 VP","workCenter.settings.modelPolicy":"\u6A21\u578B\u7B56\u7565","workCenter.settings.model.inherit":"\u7EE7\u627F VP \u504F\u597D","workCenter.settings.model.primary":"Agent \u4E3B\u6A21\u578B","workCenter.settings.model.fast":"Agent \u5FEB\u6A21\u578B","workCenter.settings.model.specific":"\u6307\u5B9A\u6A21\u578B","workCenter.settings.model":"\u6A21\u578B","workCenter.settings.effort":"\u63A8\u7406\u5F3A\u5EA6","workCenter.settings.effortDefault":"\u6A21\u578B\u9ED8\u8BA4\u503C","workCenter.settings.effortHelp":"\u8986\u76D6\u6240\u9009\u6A21\u578B\u7684\u9ED8\u8BA4\u63A8\u7406\u5F3A\u5EA6\uFF0C\u5E76\u7528\u4E8E\u6240\u6709 Work Center Action\u3002","workCenter.settings.effortChooseModelHelp":"\u9009\u62E9 Agent \u4E3B\u6A21\u578B\u3001\u5FEB\u6A21\u578B\u6216\u6307\u5B9A\u6A21\u578B\u540E\u53EF\u914D\u7F6E\u63A8\u7406\u5F3A\u5EA6\uFF1B\u7EE7\u627F VP \u504F\u597D\u65F6\u4F7F\u7528\u5404 VP \u6A21\u578B\u7684\u9ED8\u8BA4\u503C\u3002","workCenter.settings.effortUnsupportedHelp":"\u6240\u9009\u6A21\u578B\u4E0D\u63D0\u4F9B\u53EF\u914D\u7F6E\u7684\u63A8\u7406\u5F3A\u5EA6\uFF0C\u56E0\u6B64\u4F7F\u7528\u6A21\u578B\u9ED8\u8BA4\u503C\u3002","workCenter.settings.saving":"\u4FDD\u5B58\u4E2D\u2026","workCenter.settings.reload":"\u91CD\u65B0\u52A0\u8F7D\u8BBE\u7F6E","workCenter.settings.conflict":"\u8BBE\u7F6E\u5DF2\u5728\u5176\u4ED6\u4F4D\u7F6E\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u52A0\u8F7D\u540E\u518D\u4FDD\u5B58\u3002","workCenter.settings.upgradeRequired":"\u5F53\u524D Agent \u7248\u672C\u65E0\u6CD5\u4FDD\u5B58\u5DE5\u4F5C\u4E2D\u5FC3\u8BBE\u7F6E\u3002\u8FD9\u91CC\u4EE5\u53EA\u8BFB\u65B9\u5F0F\u663E\u793A\u5F53\u524D\u503C\uFF1B\u5347\u7EA7 Agent \u540E\u5373\u53EF\u7F16\u8F91\u5E76\u4FDD\u5B58\u3002","workCenter.settings.saveNotConfirmed":"Agent \u672A\u786E\u8BA4\u672C\u6B21\u63D0\u4EA4\u7684\u63D0\u793A\u8BCD\u548C\u6A21\u578B\u7B56\u7565\u3002\u8BBE\u7F6E\u7A97\u53E3\u4E0D\u4F1A\u5173\u95ED\uFF1B\u8BF7\u91CD\u65B0\u52A0\u8F7D\u6216\u5347\u7EA7 Agent \u540E\u518D\u8BD5\u3002","workCenter.settings.addWorkflow":"\u590D\u5236\u4EFB\u52A1\u6D41","workCenter.settings.removeWorkflow":"\u5220\u9664","workCenter.settings.newWorkflow":"\u4EFB\u52A1\u6D41 {index}","workCenter.settings.workflowName":"\u4EFB\u52A1\u6D41\u540D\u79F0","workCenter.settings.newStage":"\u65B0\u9636\u6BB5","workCenter.settings.addStage":"\u6DFB\u52A0\u9636\u6BB5","workCenter.settings.removeStage":"\u5220\u9664\u9636\u6BB5","workCenter.settings.moveUp":"\u4E0A\u79FB\u9636\u6BB5","workCenter.settings.moveDown":"\u4E0B\u79FB\u9636\u6BB5","workCenter.settings.stageType":"\u9636\u6BB5\u7C7B\u578B","workCenter.settings.reviewReturnStage":"\u8981\u6C42\u4FEE\u6539\u65F6\u9000\u56DE\u9636\u6BB5","workCenter.settings.instruction":"\u9636\u6BB5 Prompt","workCenter.settings.instructionHint":"\u5B9A\u4E49\u8FD9\u4E2A\u9636\u6BB5\u5177\u4F53\u8981\u505A\u4EC0\u4E48\u3002","workCenter.settings.instructionHelp":"\u8FD0\u884C\u65F6\u4F1A\u81EA\u52A8\u52A0\u5165 Work Item \u7684\u76EE\u6807\u3001\u9A8C\u6536\u6807\u51C6\u548C\u53EF\u590D\u7528\u4E0A\u4E0B\u6587\u3002","workCenter.settings.instructionReset":"\u6062\u590D\u9ED8\u8BA4\u503C"}});var Tu,Mu=F(()=>{Tu={"common.loading":"Loading...","common.confirm":"OK","common.apply":"Apply","common.cancel":"Cancel","common.delete":"Delete","common.copy":"Copy","common.copied":"Copied","common.close":"Close","common.refresh":"Refresh","common.open":"Open","common.save":"Save","common.search":"Search","common.back":"Back","common.noSubdirectories":"No subdirectories","common.drives":"Drives","common.rootDir":"Root","common.comma":", ","common.select":"Select","mermaid.export":"Export","mermaid.exportMd":"Export MD","mermaid.exportPng":"Export PNG","mermaid.exportJpg":"Export JPG","chat.toolActionsOmitted":"{count} older tool actions omitted","login.subtitle":"Yeaft Web Code Agent","login.username":"Username","login.password":"Password","login.login":"Login","login.loggingIn":"Logging in...","login.enterUsername":"Please enter your username","login.enterPassword":"Please enter your password","login.noAccount":"Don't have an account?","login.registerWithCode":"Register","login.or":"or","login.usePassword":"Sign in with username & password","login.useSso":"Back to single sign-on","login.noProviders":"No third-party sign-in providers are enabled.","login.microsoft":"Sign in with Microsoft","login.github":"Sign in with GitHub","login.google":"Sign in with Google","login.wechat":"Sign in with WeChat","login.alipay":"Sign in with Alipay","login.wechat.mobileUnsupported":"Sign in with WeChat is only available on PC. Please scan the QR code from a desktop browser.","login.alipay.mobileWaiting":"Waiting for you to confirm in the Alipay app\u2026 Once you finish, return to this page and you will be signed in automatically.","login.alipay.relaunch":"Open Alipay again","login.qr.title":"Scan to sign in","login.qr.titleAlipay":"Sign in with Alipay","login.qr.titleWechat":"Sign in with WeChat","login.qr.hint":"Scan the QR code with your phone to authorize.","login.error.enterUsername":"Please enter your username","login.error.enterPassword":"Please enter your password","login.error.enter6Digit":"Please enter a 6-digit code","login.error.enterInviteCode":"Please enter the invite code","login.error.usernameMinLen":"Username must be at least 2 characters","login.error.passwordMinLen":"Password must be at least 6 characters","login.error.passwordMismatch":"Passwords do not match","login.error.enterVerifyCode":"Please enter the verification code","login.error.loginFailed":"Login failed","login.forgot.link":"Forgot password?","login.forgot.title":"Reset your password","login.forgot.emailHint":"Enter the email address on your account. We will send a 6-digit reset code.","login.forgot.sendCode":"Send Reset Code","login.forgot.sending":"Sending...","login.forgot.codeSent":"If the email is on file, a 6-digit reset code has been sent. Enter it below along with your new password.","login.forgot.resetBtn":"Reset Password","login.forgot.resetting":"Resetting...","login.forgot.success":"Password reset. You can now sign in with your new password.","login.forgot.emailInvalid":"Please enter a valid email","login.register.title":"New User Registration","login.register.inviteCode":"Invite Code","login.register.username":"Username","login.register.password":"Password (min 6 characters)","login.register.confirmPassword":"Confirm Password","login.register.email":"Email (optional)","login.register.submit":"Register","login.register.submitting":"Registering...","login.register.back":"Back to Login","login.register.success":"Registration successful, please login","login.register.enterCode":"Please enter the invite code","login.register.usernameMin":"Username must be at least 2 characters","login.register.passwordMin":"Password must be at least 6 characters","login.register.passwordMismatch":"Passwords do not match","login.totp.setupTitle":"Set Up Two-Factor Authentication","login.totp.setupHint":"Scan the QR code below with Microsoft Authenticator or Google Authenticator","login.totp.manualKey":"Or enter the key manually:","login.totp.enterCode":"Enter 6-digit code","login.totp.complete":"Complete Setup","login.totp.verifying":"Verifying...","login.totp.verify":"Verify","login.totp.prompt":"Enter the code from your Authenticator app","login.totp.invalidCode":"Please enter a 6-digit code","login.email.codeSent":"Verification code sent to {email}","login.email.enterCode":"Enter verification code","login.email.verify":"Verify","login.email.verifying":"Verifying...","login.email.enterCodeError":"Please enter the verification code","chat.agent.select":"Select Agent","chat.agent.manage":"Manage Agents","chat.agent.none":"No Agents","chat.agent.restarting":"Restarting","chat.agent.restart":"Restart","chat.agent.restartConfirm":`Are you sure you want to restart Agent "{name}"?
|
|
13
13
|
All active conversations will be interrupted.`,"chat.agent.upgrade":"Upgrade","chat.agent.upgrading":"Upgrading","chat.agent.upgradeConfirm":`Upgrade Agent "{name}" to the latest version?
|
|
@@ -408,7 +408,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
408
408
|
`,setup(e){let t=Pinia.useChatStore(),s=Vue.inject("t"),n=Vue.computed(()=>e.conversationId||t.currentConversation),r=Vue.computed(()=>n.value&&t.conversations.find(x=>x.id===n.value)||null),i=Vue.computed(()=>r.value?.capabilities||null),o=Vue.computed(()=>n.value?(r.value?.provider||"claude-code")==="claude-code":!0),a=(x,Y=!0)=>{let oe=i.value;return oe?!!oe[x]:o.value?Y:!1},l=Vue.computed(()=>a("compact")),c=Vue.computed(()=>a("clear")),d=Vue.computed(()=>a("expert")),u=Vue.computed(()=>a("mcp")),f=Vue.computed(()=>{if(!n.value)return"Yeaft";let x=t.getConversationTitle(n.value);if(x)return x;let oe=t.conversations.find(he=>he.id===n.value)?.workDir||t.currentWorkDir;if(oe){let he=oe.split(/[/\\]/);return he[he.length-1]||he[he.length-2]||oe}return s("chatHeader.newConv")}),p=Vue.computed(()=>{if(!n.value)return"";let Y=t.conversations.find(he=>he.id===n.value)?.agentId;return Y&&t.agents.find(he=>he.id===Y)?.name||""}),g=Vue.computed(()=>t.clearStatus?.conversationId===n.value?!0:t.compactStatus?t.compactStatus.conversationId===n.value:!1),b=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?"compacting":"completed":t.compactStatus?t.compactStatus.status==="compacting"?"compacting":"completed":""),h=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing":t.compactStatus?.status==="compacting"),A=Vue.computed(()=>t.clearStatus?.conversationId===n.value?t.clearStatus.status==="clearing"?s("chatHeader.clearing"):s("chatHeader.clearDone"):t.compactStatus?t.compactStatus.status==="compacting"?t.compactStatus.message||s("chatHeader.compacting"):t.compactStatus.message||s("chatHeader.compactDone"):""),w=Vue.computed(()=>n.value&&(t.conversations.find(Y=>Y.id===n.value)?.workDir||t.currentWorkDir)||""),S=Vue.computed(()=>!t.contextUsage||t.contextUsage.conversationId!==n.value?null:t.contextUsage),y=Vue.computed(()=>{let x=S.value?.percentage||0;return x>=80?"context-danger":x>=50?"context-warn":"context-ok"}),m=Vue.computed(()=>{if(!S.value)return"";let x=(S.value.inputTokens/1e3).toFixed(0),Y=(S.value.maxTokens/1e3).toFixed(0);return`Context: ${x}k / ${Y}k`}),v=Vue.computed(()=>t.isRefreshingSession(n.value)),E=Vue.computed(()=>t.compactStatus?.status==="compacting"&&t.compactStatus?.conversationId===n.value),V=Vue.computed(()=>t.clearStatus?.status==="clearing"&&t.clearStatus?.conversationId===n.value),U=Vue.computed(()=>n.value?!t.isRefreshingSession(n.value):!1),L=()=>{t.isRefreshingSession(n.value)||!n.value||(t.setRefreshingSession(n.value,!0),t.startRefreshTimeout(n.value),t.processingConversations[n.value]||(t.messagesMap[n.value]=[]),t.requestChatHistory(n.value,{mode:"recent",turns:5}))},D=()=>{E.value||t.sendMessage("/compact")},M=()=>{window.location.reload()},T=()=>{V.value||confirm(s("chatHeader.confirmClear"))&&(t.clearStatus={conversationId:n.value,status:"clearing"},t.sendMessage("/clear"))},C=Vue.computed(()=>t.getPaneRightPanel(e.paneId)),R=Vue.ref(null),B=Vue.computed(()=>{if(!t.mcpPanelOpen||!R.value)return null;let x=R.value.getBoundingClientRect();return{top:`${x.bottom+6}px`,right:`${window.innerWidth-x.right}px`}}),O=Vue.computed(()=>t.currentMcpServers.filter(x=>x.enabled).length),j=Vue.computed(()=>!!t.conversations.find(Y=>Y.id===n.value)?.needRestart),ne=()=>{t.mcpPanelOpen=!t.mcpPanelOpen},ve=()=>{t.togglePaneRightPanel("experts",e.paneId)},ue=()=>{t.togglePaneRightPanel("subagents",e.paneId)},be=Vue.computed(()=>t.runningSubagentCount),ie=(x,Y)=>{t.toggleConversationMcp(x,Y)},Ce=x=>{t.mcpPanelOpen&&!x.target.closest(".mcp-dropdown")&&!x.target.closest(".mcp-config-wrapper")&&(t.mcpPanelOpen=!1)};return Vue.onMounted(()=>{document.addEventListener("click",Ce)}),Vue.onUnmounted(()=>{document.removeEventListener("click",Ce)}),{store:t,effectiveConvId:n,effectiveRightPanel:C,isClaudeCode:o,canCompact:l,canClear:c,canExpert:d,canMcp:u,headerTitle:f,showStatusBanner:g,statusBannerClass:b,statusBannerSpinner:h,statusBannerMessage:A,contextUsage:S,contextColorClass:y,contextLabel:m,isRefreshing:v,isCompacting:E,isClearing:V,canRefresh:U,refreshSession:L,reloadPage:M,compactContext:D,clearMessages:T,mcpBtnRef:R,mcpDropdownStyle:B,mcpEnabledCount:O,currentConvNeedRestart:j,toggleMcpPanel:ne,toggleMcpServer:ie,toggleExpertPanel:ve,toggleSubAgentPanel:ue,runningSubagentCount:be}}}});function On(e=globalThis.location){let t=e?.protocol==="https:"?"wss:":"ws:",s=e?.host||"localhost";return`${t}//${s}`}function Xr(){return"npm install -g @yeaft/webchat-agent"}function Zr(){return"yeaft-agent llm use github-copilot --model gpt-5.5"}function va(e=null){let t=e&&(e.username||e.displayName)||"agent",s=2166136261;for(let i=0;i<t.length;i++)s^=t.charCodeAt(i),s=s+((s<<1)+(s<<4)+(s<<7)+(s<<8)+(s<<24))>>>0;let n=s.toString(16).padStart(8,"0").slice(0,6);return`${String(t).replace(/[^A-Za-z0-9_-]/g,"-").replace(/^-+|-+$/g,"")||"agent"}-${n}`}function Jr({profile:e=null,agentSecret:t="",serverWsUrl:s=On()}={}){if(!t)return"";let n=va(e);return`yeaft-agent install --server ${s} --secret ${t} --name ${n}`}var ya=F(()=>{});function js(e,{alt:t="Preview",closeLabel:s="Close",trigger:n=null}={}){if(!e)return;let r=document.createElement("div");r.className="image-preview-overlay",r.setAttribute("role","dialog"),r.setAttribute("aria-modal","true"),r.setAttribute("aria-label",t);let i=document.createElement("img");i.className="image-preview-img",i.src=e,i.alt=t;let o=document.createElement("button");o.type="button",o.className="image-preview-close",o.setAttribute("aria-label",s),o.textContent="\xD7",r.append(i,o),document.body.appendChild(r),r.offsetHeight,r.classList.add("visible"),o.focus();let a=!1,l=()=>r.remove(),c=()=>{a||(a=!0,r.classList.remove("visible"),r.addEventListener("transitionend",l,{once:!0}),setTimeout(l,250),document.removeEventListener("keydown",d),n?.isConnected&&typeof n.focus=="function"&&n.focus())},d=u=>{u.key==="Escape"&&c(),u.key==="Tab"&&(u.preventDefault(),o.focus())};o.addEventListener("click",c),r.addEventListener("click",u=>{u.target===r&&c()}),document.addEventListener("keydown",d)}var ei=F(()=>{});function lv(e){let t=[];for(let s of e)s==="\b"?t.pop():t.push(s);return t.join("")}function cv(e){let t=e.split("\r"),s=t[t.length-1]||"";return lv(s)}function $u(e){return e.replace(/\r\n/g,`
|
|
409
409
|
`).split(`
|
|
410
410
|
`).map(t=>cv(t)).join(`
|
|
411
|
-
`)}function Vu(e){return e.replace(ov,"").replace(av,"")}function dv(e){return e?e.split(";").filter(t=>t!=="").map(t=>Number(t)).filter(Number.isFinite):[0]}function _u(e,t){let s=t==="bg"&&e>=30&&e<=37||t==="bg"&&e>=90&&e<=97?e+10:e;return t==="bg"?Sa.get(s):ka.get(s)}function Eu(e,t,s){let n=Ia[0],r=1/0;for(let i of Ia){let o=(i.r-e)**2+(i.g-t)**2+(i.b-s)**2;o<r&&(n=i,r=o)}return n.code}function uv(e){if(e<0||e>255)return null;if(e<16){let s=Ia[e];return{r:s.r,g:s.g,b:s.b}}if(e>=232){let s=8+(e-232)*10;return{r:s,g:s,b:s}}let t=e-16;return{r:wa[Math.floor(t/36)],g:wa[Math.floor(t%36/6)],b:wa[t%6]}}function Du(e,t,s,n){let r=s[n+1];if(r===5){let i=s[n+2];if(Number.isFinite(i)){let o=uv(i);o&&(e[t]=_u(Eu(o.r,o.g,o.b),t)||"")}return n+3}if(r===2){let i=s[n+2],o=s[n+3],a=s[n+4];return Number.isFinite(i)&&Number.isFinite(o)&&Number.isFinite(a)&&(e[t]=_u(Eu(i,o,a),t)||""),n+5}return n+2}function pv(e,t){let s={...e},n=t.length?t:[0];for(let r=0;r<n.length;){let i=n[r];if(i===0)s.fg="",s.bg="",s.bold=!1,s.dim=!1,s.italic=!1,s.underline=!1;else if(i===1)s.bold=!0,s.dim=!1;else if(i===2)s.dim=!0,s.bold=!1;else if(i===3)s.italic=!0;else if(i===4)s.underline=!0;else if(i===22)s.bold=!1,s.dim=!1;else if(i===23)s.italic=!1;else if(i===24)s.underline=!1;else if(i===39)s.fg="";else if(i===49)s.bg="";else if(ka.has(i))s.fg=ka.get(i);else if(Sa.has(i))s.bg=Sa.get(i);else if(i===38){r=Du(s,"fg",n,r);continue}else if(i===48){r=Du(s,"bg",n,r);continue}r+=1}return s}function fv(e){return[e.fg,e.bg,e.bold&&"terminal-bold",e.dim&&"terminal-dim",e.italic&&"terminal-italic",e.underline&&"terminal-underline"].filter(Boolean).join(" ")}function Lu(e,t,s){let n=Vu(t);if(!n)return;let r=fv(s),i=e[e.length-1];i&&i.className===r?i.text+=n:e.push({text:n,className:r})}function Rt(e){if(e==null)return"";let t=typeof e=="string"?e:String(e);return t?Vu($u(t)):""}function Fu(e){if(e==null)return[];let t=typeof e=="string"?e:String(e);if(!t)return[];let s=$u(t),n=[],r={fg:"",bg:"",bold:!1,dim:!1,italic:!1,underline:!1},i=0;ba.lastIndex=0;for(let o=ba.exec(s);o;o=ba.exec(s))Lu(n,s.slice(i,o.index),r),r=pv(r,dv(o[1])),i=o.index+o[0].length;return Lu(n,s.slice(i),r),n}var ov,ba,av,ka,Sa,Ia,wa,Hn=F(()=>{ov=/[\u001b\u009b](?:[\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\][^\u0007]*(?:\u0007|\u001b\\)|[PX^_][\s\S]*?\u001b\\)/g,ba=/(?:\u001b\[|\u009b)([0-9;]*)m/g,av=/[\u0000-\u0008\u000b\u000c\u000e-\u001a\u001c-\u001f\u007f-\u009f]/g,ka=new Map([[30,"terminal-fg-black"],[31,"terminal-fg-red"],[32,"terminal-fg-green"],[33,"terminal-fg-yellow"],[34,"terminal-fg-blue"],[35,"terminal-fg-magenta"],[36,"terminal-fg-cyan"],[37,"terminal-fg-white"],[90,"terminal-fg-bright-black"],[91,"terminal-fg-bright-red"],[92,"terminal-fg-bright-green"],[93,"terminal-fg-bright-yellow"],[94,"terminal-fg-bright-blue"],[95,"terminal-fg-bright-magenta"],[96,"terminal-fg-bright-cyan"],[97,"terminal-fg-bright-white"]]),Sa=new Map([[40,"terminal-bg-black"],[41,"terminal-bg-red"],[42,"terminal-bg-green"],[43,"terminal-bg-yellow"],[44,"terminal-bg-blue"],[45,"terminal-bg-magenta"],[46,"terminal-bg-cyan"],[47,"terminal-bg-white"],[100,"terminal-bg-bright-black"],[101,"terminal-bg-bright-red"],[102,"terminal-bg-bright-green"],[103,"terminal-bg-bright-yellow"],[104,"terminal-bg-bright-blue"],[105,"terminal-bg-bright-magenta"],[106,"terminal-bg-bright-cyan"],[107,"terminal-bg-bright-white"]]),Ia=[{code:30,r:0,g:0,b:0},{code:31,r:170,g:0,b:0},{code:32,r:0,g:170,b:0},{code:33,r:170,g:85,b:0},{code:34,r:0,g:0,b:170},{code:35,r:170,g:0,b:170},{code:36,r:0,g:170,b:170},{code:37,r:170,g:170,b:170},{code:90,r:85,g:85,b:85},{code:91,r:255,g:85,b:85},{code:92,r:85,g:255,b:85},{code:93,r:255,g:255,b:85},{code:94,r:85,g:85,b:255},{code:95,r:255,g:85,b:255},{code:96,r:85,g:255,b:255},{code:97,r:255,g:255,b:255}],wa=[0,95,135,175,215,255]});var zs,ti=F(()=>{ei();_n();Hn();
|
|
411
|
+
`)}function Vu(e){return e.replace(ov,"").replace(av,"")}function dv(e){return e?e.split(";").filter(t=>t!=="").map(t=>Number(t)).filter(Number.isFinite):[0]}function _u(e,t){let s=t==="bg"&&e>=30&&e<=37||t==="bg"&&e>=90&&e<=97?e+10:e;return t==="bg"?Sa.get(s):ka.get(s)}function Eu(e,t,s){let n=Ia[0],r=1/0;for(let i of Ia){let o=(i.r-e)**2+(i.g-t)**2+(i.b-s)**2;o<r&&(n=i,r=o)}return n.code}function uv(e){if(e<0||e>255)return null;if(e<16){let s=Ia[e];return{r:s.r,g:s.g,b:s.b}}if(e>=232){let s=8+(e-232)*10;return{r:s,g:s,b:s}}let t=e-16;return{r:wa[Math.floor(t/36)],g:wa[Math.floor(t%36/6)],b:wa[t%6]}}function Du(e,t,s,n){let r=s[n+1];if(r===5){let i=s[n+2];if(Number.isFinite(i)){let o=uv(i);o&&(e[t]=_u(Eu(o.r,o.g,o.b),t)||"")}return n+3}if(r===2){let i=s[n+2],o=s[n+3],a=s[n+4];return Number.isFinite(i)&&Number.isFinite(o)&&Number.isFinite(a)&&(e[t]=_u(Eu(i,o,a),t)||""),n+5}return n+2}function pv(e,t){let s={...e},n=t.length?t:[0];for(let r=0;r<n.length;){let i=n[r];if(i===0)s.fg="",s.bg="",s.bold=!1,s.dim=!1,s.italic=!1,s.underline=!1;else if(i===1)s.bold=!0,s.dim=!1;else if(i===2)s.dim=!0,s.bold=!1;else if(i===3)s.italic=!0;else if(i===4)s.underline=!0;else if(i===22)s.bold=!1,s.dim=!1;else if(i===23)s.italic=!1;else if(i===24)s.underline=!1;else if(i===39)s.fg="";else if(i===49)s.bg="";else if(ka.has(i))s.fg=ka.get(i);else if(Sa.has(i))s.bg=Sa.get(i);else if(i===38){r=Du(s,"fg",n,r);continue}else if(i===48){r=Du(s,"bg",n,r);continue}r+=1}return s}function fv(e){return[e.fg,e.bg,e.bold&&"terminal-bold",e.dim&&"terminal-dim",e.italic&&"terminal-italic",e.underline&&"terminal-underline"].filter(Boolean).join(" ")}function Lu(e,t,s){let n=Vu(t);if(!n)return;let r=fv(s),i=e[e.length-1];i&&i.className===r?i.text+=n:e.push({text:n,className:r})}function Rt(e){if(e==null)return"";let t=typeof e=="string"?e:String(e);return t?Vu($u(t)):""}function Fu(e){if(e==null)return[];let t=typeof e=="string"?e:String(e);if(!t)return[];let s=$u(t),n=[],r={fg:"",bg:"",bold:!1,dim:!1,italic:!1,underline:!1},i=0;ba.lastIndex=0;for(let o=ba.exec(s);o;o=ba.exec(s))Lu(n,s.slice(i,o.index),r),r=pv(r,dv(o[1])),i=o.index+o[0].length;return Lu(n,s.slice(i),r),n}var ov,ba,av,ka,Sa,Ia,wa,Hn=F(()=>{ov=/[\u001b\u009b](?:[\[\]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><~]|\][^\u0007]*(?:\u0007|\u001b\\)|[PX^_][\s\S]*?\u001b\\)/g,ba=/(?:\u001b\[|\u009b)([0-9;]*)m/g,av=/[\u0000-\u0008\u000b\u000c\u000e-\u001a\u001c-\u001f\u007f-\u009f]/g,ka=new Map([[30,"terminal-fg-black"],[31,"terminal-fg-red"],[32,"terminal-fg-green"],[33,"terminal-fg-yellow"],[34,"terminal-fg-blue"],[35,"terminal-fg-magenta"],[36,"terminal-fg-cyan"],[37,"terminal-fg-white"],[90,"terminal-fg-bright-black"],[91,"terminal-fg-bright-red"],[92,"terminal-fg-bright-green"],[93,"terminal-fg-bright-yellow"],[94,"terminal-fg-bright-blue"],[95,"terminal-fg-bright-magenta"],[96,"terminal-fg-bright-cyan"],[97,"terminal-fg-bright-white"]]),Sa=new Map([[40,"terminal-bg-black"],[41,"terminal-bg-red"],[42,"terminal-bg-green"],[43,"terminal-bg-yellow"],[44,"terminal-bg-blue"],[45,"terminal-bg-magenta"],[46,"terminal-bg-cyan"],[47,"terminal-bg-white"],[100,"terminal-bg-bright-black"],[101,"terminal-bg-bright-red"],[102,"terminal-bg-bright-green"],[103,"terminal-bg-bright-yellow"],[104,"terminal-bg-bright-blue"],[105,"terminal-bg-bright-magenta"],[106,"terminal-bg-bright-cyan"],[107,"terminal-bg-bright-white"]]),Ia=[{code:30,r:0,g:0,b:0},{code:31,r:170,g:0,b:0},{code:32,r:0,g:170,b:0},{code:33,r:170,g:85,b:0},{code:34,r:0,g:0,b:170},{code:35,r:170,g:0,b:170},{code:36,r:0,g:170,b:170},{code:37,r:170,g:170,b:170},{code:90,r:85,g:85,b:85},{code:91,r:255,g:85,b:85},{code:92,r:85,g:255,b:85},{code:93,r:255,g:255,b:85},{code:94,r:85,g:85,b:255},{code:95,r:255,g:85,b:255},{code:96,r:85,g:255,b:255},{code:97,r:255,g:255,b:255}],wa=[0,95,135,175,215,255]});var zs,ti=F(()=>{ei();_n();Hn();cs();zs={name:"MessageItem",props:{message:{type:Object,required:!0},sessionActions:{type:Boolean,default:!1}},emits:["quote","edit-as-new"],template:`
|
|
412
412
|
<div :class="messageClass">
|
|
413
413
|
<!-- User message -->
|
|
414
414
|
<template v-if="message.type === 'user'">
|
|
@@ -494,7 +494,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
494
494
|
{{ displayContent }}
|
|
495
495
|
</template>
|
|
496
496
|
</div>
|
|
497
|
-
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(!1),n=Vue.inject("t"),r=Vue.computed(()=>["message",e.message.type]),i=()=>{let h=e.message;return typeof h.timestamp=="number"&&h.timestamp>0?h.timestamp:typeof h.createdAt=="number"&&h.createdAt>0?h.createdAt:null},o=Vue.computed(()=>vt(i())),a=Vue.computed(()=>{let h=i();if(!h)return"";try{return new Date(h).toLocaleString()}catch{return""}}),l=Vue.computed(()=>Rt(e.message.content||"")),c=Vue.computed(()=>qd(e.message,n("message.you")));return{messageClass:r,messageTime:o,messageTimeFull:a,displayContent:l,userQuote:c,showAttachments:s,toggleAttachments:()=>{s.value=!s.value},previewAttachment:(h,A)=>{h?.preview&&js(h.preview,{alt:h.name||n("message.imagePreview"),closeLabel:n("common.close"),trigger:A})},t:n,formatExpertLabel:h=>
|
|
497
|
+
`,setup(e){let t=Pinia.useChatStore(),s=Vue.ref(!1),n=Vue.inject("t"),r=Vue.computed(()=>["message",e.message.type]),i=()=>{let h=e.message;return typeof h.timestamp=="number"&&h.timestamp>0?h.timestamp:typeof h.createdAt=="number"&&h.createdAt>0?h.createdAt:null},o=Vue.computed(()=>vt(i())),a=Vue.computed(()=>{let h=i();if(!h)return"";try{return new Date(h).toLocaleString()}catch{return""}}),l=Vue.computed(()=>Rt(e.message.content||"")),c=Vue.computed(()=>qd(e.message,n("message.you")));return{messageClass:r,messageTime:o,messageTimeFull:a,displayContent:l,userQuote:c,showAttachments:s,toggleAttachments:()=>{s.value=!s.value},previewAttachment:(h,A)=>{h?.preview&&js(h.preview,{alt:h.name||n("message.imagePreview"),closeLabel:n("common.close"),trigger:A})},t:n,formatExpertLabel:h=>os(h,t.customExpertRoles),getAttachmentsText:h=>{if(!h||h.length===0)return"";let A=h.filter(y=>y.isImage).length,w=h.length-A,S=[];return A>0&&S.push(n("message.imageCount",{count:A})),w>0&&S.push(n("message.fileCount",{count:w})),S.join(n("common.comma"))},todoStatusSymbol:h=>h==="completed"?"\u2713":h==="in_progress"?"\u2192":"\u25CB",getFileIcon:h=>h?h.startsWith("image/")?"\u{1F5BC}\uFE0F":h.startsWith("video/")?"\u{1F3AC}":h.startsWith("audio/")?"\u{1F3B5}":h.includes("pdf")?"\u{1F4D5}":h.includes("word")||h.includes("document")?"\u{1F4DD}":h.includes("sheet")||h.includes("excel")?"\u{1F4CA}":h.includes("presentation")||h.includes("powerpoint")?"\u{1F4FD}\uFE0F":h.includes("zip")||h.includes("compressed")||h.includes("archive")?"\u{1F4E6}":h.includes("text")||h.includes("json")||h.includes("xml")?"\u{1F4C3}":"\u{1F4C4}":"\u{1F4C4}"}}}});function Ca(e){let t=e&&typeof e.to=="string"&&e.to.trim()?e.to.trim():"?",s=t==="all"?"@all":`@${t}`,n=typeof e?.text=="string"?e.text.trim():"",r=typeof e?.reason=="string"?e.reason.trim():"";return{to:t,target:s,text:n,reason:r}}function Ou(e,t=s=>s){let s=Ca(e);return s.text?`Route ${s.target}: ${t(s.text,70)}`:`Route ${s.target}`}var Aa=F(()=>{});var si,xa=F(()=>{Hn();si={name:"TerminalOutput",props:{content:{default:""}},template:`
|
|
498
498
|
<pre class="terminal-output"><code><template v-for="(token, index) in tokens" :key="index"><span v-if="token.className" :class="token.className">{{ token.text }}</span><template v-else>{{ token.text }}</template></template></code></pre>
|
|
499
499
|
`,setup(e){return{tokens:Vue.computed(()=>Fu(e.content))}}}});var ni,Ta=F(()=>{Aa();Hn();xa();ni={name:"ToolLine",components:{TerminalOutput:si},props:{toolName:{type:String,required:!0},toolInput:{type:Object,default:null},toolResult:{default:null},hasResult:{type:Boolean,default:!1},compact:{type:Boolean,default:!1},startTime:{type:Number,default:0},expanded:{type:Boolean,default:null}},emits:["update:expanded"],template:`
|
|
500
500
|
<div>
|
|
@@ -628,7 +628,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
628
628
|
>{{ subtitle }}</span>
|
|
629
629
|
</span>
|
|
630
630
|
</span>
|
|
631
|
-
`,setup(e){let t=yt(),s=Vue.computed(()=>t.vpLabel(e.vpId)),n=Vue.computed(()=>{let i=t.vpById(e.vpId);return i&&(i.subtitle||i.role)||""}),r=Vue.computed(()=>({color:t.vpTextColor(e.vpId)}));return{displayName:s,subtitle:n,nameStyle:r}}}});var ri,Ma=F(()=>{Bu();Br();
|
|
631
|
+
`,setup(e){let t=yt(),s=Vue.computed(()=>t.vpLabel(e.vpId)),n=Vue.computed(()=>{let i=t.vpById(e.vpId);return i&&(i.subtitle||i.role)||""}),r=Vue.computed(()=>({color:t.vpTextColor(e.vpId)}));return{displayName:s,subtitle:n,nameStyle:r}}}});var ri,Ma=F(()=>{Bu();Br();cs();ri={name:"VpSpeakerHeader",components:{VpBadge:Nu},emits:["stop-turn"],props:{vpId:{type:String,required:!0},timestamp:{type:Number,default:0},stateCause:{type:String,default:""},turnId:{type:String,default:""},showStop:{type:Boolean,default:!1}},template:`
|
|
632
632
|
<div class="vp-speaker-header" :data-vp-id="vpId">
|
|
633
633
|
<VpBadge
|
|
634
634
|
:vp-id="vpId"
|
|
@@ -655,7 +655,7 @@ The agent will restart after upgrading.`,"chat.agent.alreadyLatest":"Agent is al
|
|
|
655
655
|
:title="$t ? $t('yeaft.vp.speaker.stop') : 'Stop'"
|
|
656
656
|
><svg viewBox="0 0 24 24" width="14" height="14"><rect x="6" y="6" width="12" height="12" rx="2" fill="currentColor"/></svg></button>
|
|
657
657
|
</div>
|
|
658
|
-
`,setup(e){let t=
|
|
658
|
+
`,setup(e){let t=fs(),s=Vue.computed(()=>t.isVpTypingInCurrentConv(e.vpId)),n=Vue.computed(()=>vt(e.timestamp)),r=Vue.computed(()=>{if(!e.timestamp)return"";try{return new Date(e.timestamp).toLocaleString()}catch{return""}});return{isTyping:s,timestampText:n,timestampFullText:r}}}});function Wu(e,t){let s=t?.status||"pending",n=!!e&&e.isStreaming!==!0,i=s==="in_progress"&&n?"stopped":s;return{...t,rawStatus:s,displayStatus:i,displayText:i==="in_progress"?t?.activeForm||t?.content||"":t?.content||""}}var Uu=F(()=>{});function Pa(e,t){return`${String(e||"mermaid-diagram").replace(/[^a-z0-9_-]+/gi,"-").replace(/^-+|-+$/g,"")||"mermaid-diagram"}.${t}`}function mv(e){if(typeof document>"u")return String(e||"").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'");let t=document.createElement("textarea");return t.innerHTML=String(e||""),t.value}function hv(e,t){return e!=="mermaid"?"":` data-mermaid-source="${encodeURIComponent(mv(t))}"`}function vv(e){let t=e?.dataset?.mermaidSource;if(!t)return"";try{return decodeURIComponent(t)}catch{return""}}function Yu(e,t){let s=document.createElement("a");s.href=e,s.download=t,document.body.appendChild(s),s.click(),s.remove()}function Gu(e,t){let s=URL.createObjectURL(e);Yu(s,t),setTimeout(()=>URL.revokeObjectURL(s),0)}function yv(e){let t=o=>{let a=Number.parseFloat(String(o||"").replace("px",""));return Number.isFinite(a)&&a>0?a:null},s=t(e.getAttribute("width")),n=t(e.getAttribute("height"));if(s&&n)return{width:s,height:n};let r=e.getAttribute("viewBox");if(r){let o=r.trim().split(/\s+/).map(Number.parseFloat);if(o.length===4&&o.every(a=>Number.isFinite(a))&&o[2]>0&&o[3]>0)return{width:o[2],height:o[3]}}let i=e.getBoundingClientRect?.();return i?.width&&i?.height?{width:i.width,height:i.height}:{width:1200,height:800}}function Qu(e,t){return typeof getComputedStyle>"u"||typeof document>"u"?t:getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function bv(e,t,s){e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("width",String(t)),e.setAttribute("height",String(s)),e.getAttribute("viewBox")||e.setAttribute("viewBox",`0 0 ${t} ${s}`)}async function wv(e,t,s,n){if(!window.htmlToImage)return!1;let r=Pa("mermaid-diagram",t==="jpg"?"jpg":"png"),i={backgroundColor:Qu("--bg-main","white"),height:n,pixelRatio:Math.max(1,Math.min(3,window.devicePixelRatio||1)),style:{margin:"0"},width:s},o=t==="jpg"?await window.htmlToImage.toJpeg(e,{...i,quality:.92}):await window.htmlToImage.toPng(e,i);return Yu(o,r),!0}async function Ku(e,t){let s=e.querySelector("svg");if(!s)throw new Error("No Mermaid SVG found");let{width:n,height:r}=yv(s);try{if(await wv(s,t,n,r))return}catch{}let i=s.cloneNode(!0);bv(i,n,r);let o=new XMLSerializer().serializeToString(i),a=new Blob([o],{type:"image/svg+xml;charset=utf-8"}),l=URL.createObjectURL(a);try{let c=new Image,d=new Promise((h,A)=>{c.onload=h,c.onerror=()=>A(new Error("Failed to load Mermaid SVG for export"))});c.src=l,await d;let u=Math.max(1,Math.min(3,window.devicePixelRatio||1)),f=document.createElement("canvas");f.width=Math.ceil(n*u),f.height=Math.ceil(r*u);let p=f.getContext("2d");if(!p)throw new Error("Canvas is not available");p.scale(u,u),t==="jpg"&&(p.fillStyle=Qu("--bg-main","white"),p.fillRect(0,0,n,r)),p.drawImage(c,0,0,n,r);let g=t==="jpg"?"image/jpeg":"image/png",b=await new Promise((h,A)=>{f.toBlob(w=>w?h(w):A(new Error("Failed to export Mermaid image")),g,.92)});Gu(b,Pa("mermaid-diagram",t==="jpg"?"jpg":"png"))}finally{URL.revokeObjectURL(l)}}function kv(e){let t=`\`\`\`mermaid
|
|
659
659
|
${String(e||"").trim()}
|
|
660
660
|
\`\`\`
|
|
661
661
|
`;Gu(new Blob([t],{type:"text/markdown;charset=utf-8"}),Pa("mermaid-diagram","md"))}function Sv(e,t){let s=document.createElement("div");s.className="mermaid-export-controls",s.setAttribute("aria-label",Ee("mermaid.export"));let n=[{label:Ee("mermaid.exportMd"),action:()=>kv(t)},{label:Ee("mermaid.exportPng"),action:()=>Ku(e,"png")},{label:Ee("mermaid.exportJpg"),action:()=>Ku(e,"jpg")}];for(let r of n){let i=document.createElement("button");i.type="button",i.className="mermaid-export-btn",i.textContent=r.label,i.title=r.label,i.addEventListener("click",async o=>{o.preventDefault(),o.stopPropagation();try{await r.action()}catch{}}),s.appendChild(i)}return s}function Iv(){ju||typeof marked>"u"||(marked.setOptions({highlight:(e,t)=>{if(typeof hljs<"u"&&t&&hljs.getLanguage(t))try{return hljs.highlight(e,{language:t}).value}catch{}return e},breaks:!0,gfm:!0}),ju=!0)}function Cv(e){return e.replace(/<pre><code([^>]*)>([\s\S]*?)<\/code><\/pre>/g,(t,s,n)=>{let r=s.match(/class="language-(\w+)"/),i=r?r[1]:"",o=hv(i,n);return`<div class="code-block-wrapper">
|
|
@@ -668,7 +668,7 @@ ${String(e||"").trim()}
|
|
|
668
668
|
</button>
|
|
669
669
|
</div>
|
|
670
670
|
<pre><code${s}${o}>${n}</code></pre>
|
|
671
|
-
</div>`})}function Av(e){return e.replace(/<table>([\s\S]*?)<\/table>/g,t=>`<div class="table-scroll-wrapper">${t}</div>`)}function xv(){if(typeof mermaid>"u")return!1;let e=document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default";if(zu===e)return!0;try{return mermaid.initialize({startOnLoad:!1,theme:e,securityLevel:"strict"}),zu=e,!0}catch{return!1}}async function Ye(e){if(!e||!xv())return;let t=e.querySelectorAll("pre code.language-mermaid:not([data-mermaid-error])");for(let s of t){let n=s.closest("pre");if(!n||n.dataset.mermaidRendered==="true")continue;let r=n.closest(".code-block-wrapper"),i=vv(s)||s.textContent||"";if(i.trim()){n.dataset.mermaidRendered="true";try{let o=`mermaid-${Date.now()}-${gv++}`,{svg:a}=await mermaid.render(o,i),l=document.createElement("div");l.className="mermaid-rendered",l.innerHTML=a,l.dataset.mermaidSource=i,l.appendChild(Sv(l,i)),(r||n).replaceWith(l)}catch{n.dataset.mermaidRendered="false",s.dataset.mermaidError="true"}}}}function Tv(e){if(!e||typeof e!="string")return"";let t=s=>{let n=document.createElement("div");return n.textContent=s,n.innerHTML};return e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,r)=>{let i=r.trim(),o=n==="mermaid"?` data-mermaid-source="${encodeURIComponent(i)}"`:"";return`<div class="code-block-wrapper"><pre><code class="language-${n}"${o}>${t(i)}</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>")}function Mv(e){if(!e||typeof e!="string")return"";let t=e;return t=t.replace(/---\s*ROUTE\s*---[\s\S]*?---\s*(?:END[_ \-]?ROUTE|ENDROUTE|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?---\s*(?:END[_ \-]?TASKS|ENDTASKS|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*ROUTE\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*ROUTE)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*TASKS)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t}function ii(e){if(!e||typeof e!="string"||(e=Mv(e),!e))return"";let t=qn.get(e);if(t!==void 0)return t;Iv();let s;if(typeof marked<"u")try{s=Av(Cv(marked.parse(e)))}catch{}if(s||(s=Tv(e)),qn.size>=Pv){let n=qn.keys().next().value;qn.delete(n)}return qn.set(e,s),s}var ju,zu,gv,qn,Pv,Nn=F(()=>{xt();ju=!1,zu=null,gv=0;qn=new Map,Pv=2e3});var Ks,oi=F(()=>{Ta();qu();Ma();Hn();Aa();Uu();Nn();ei();
|
|
671
|
+
</div>`})}function Av(e){return e.replace(/<table>([\s\S]*?)<\/table>/g,t=>`<div class="table-scroll-wrapper">${t}</div>`)}function xv(){if(typeof mermaid>"u")return!1;let e=document.documentElement.getAttribute("data-theme")==="dark"?"dark":"default";if(zu===e)return!0;try{return mermaid.initialize({startOnLoad:!1,theme:e,securityLevel:"strict"}),zu=e,!0}catch{return!1}}async function Ye(e){if(!e||!xv())return;let t=e.querySelectorAll("pre code.language-mermaid:not([data-mermaid-error])");for(let s of t){let n=s.closest("pre");if(!n||n.dataset.mermaidRendered==="true")continue;let r=n.closest(".code-block-wrapper"),i=vv(s)||s.textContent||"";if(i.trim()){n.dataset.mermaidRendered="true";try{let o=`mermaid-${Date.now()}-${gv++}`,{svg:a}=await mermaid.render(o,i),l=document.createElement("div");l.className="mermaid-rendered",l.innerHTML=a,l.dataset.mermaidSource=i,l.appendChild(Sv(l,i)),(r||n).replaceWith(l)}catch{n.dataset.mermaidRendered="false",s.dataset.mermaidError="true"}}}}function Tv(e){if(!e||typeof e!="string")return"";let t=s=>{let n=document.createElement("div");return n.textContent=s,n.innerHTML};return e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,r)=>{let i=r.trim(),o=n==="mermaid"?` data-mermaid-source="${encodeURIComponent(i)}"`:"";return`<div class="code-block-wrapper"><pre><code class="language-${n}"${o}>${t(i)}</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>")}function Mv(e){if(!e||typeof e!="string")return"";let t=e;return t=t.replace(/---\s*ROUTE\s*---[\s\S]*?---\s*(?:END[_ \-]?ROUTE|ENDROUTE|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?---\s*(?:END[_ \-]?TASKS|ENDTASKS|END)\s*:?\s*---/gi,"").trim(),t=t.replace(/---\s*ROUTE\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*ROUTE)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t=t.replace(/---\s*TASKS\s*---[\s\S]*?(?=\n[ \t]*\n+(?:---(?!\s*TASKS)|<(?:kanban|recent-routes|task-context)\b)|$)/gi,"").trim(),t}function ii(e){if(!e||typeof e!="string"||(e=Mv(e),!e))return"";let t=qn.get(e);if(t!==void 0)return t;Iv();let s;if(typeof marked<"u")try{s=Av(Cv(marked.parse(e)))}catch{}if(s||(s=Tv(e)),qn.size>=Pv){let n=qn.keys().next().value;qn.delete(n)}return qn.set(e,s),s}var ju,zu,gv,qn,Pv,Nn=F(()=>{xt();ju=!1,zu=null,gv=0;qn=new Map,Pv=2e3});var Ks,oi=F(()=>{Ta();qu();Ma();Hn();Aa();Uu();Nn();ei();cs();Ks={name:"AssistantTurn",components:{ToolLine:ni,AskCard:Hu,VpSpeakerHeader:ri},props:{turn:{type:Object,required:!0},conversationId:{type:String,default:null},hideSpeakerHeader:{type:Boolean,default:!1},actionsExpanded:{type:Boolean,default:null},toolExpandStates:{type:Object,default:null},toolStatePrefix:{type:String,default:""},responseCollapsible:{type:Boolean,default:!1},responseCollapsed:{type:Boolean,default:!1},responseToggleLabel:{type:String,default:""},sessionActions:{type:Boolean,default:!1},quoteAuthor:{type:String,default:""}},emits:["update-actions-expanded","update-tool-expanded","toggle-response-collapse","quote"],template:`
|
|
672
672
|
<div class="assistant-turn" ref="turnRef" :class="{ streaming: turn.isStreaming, 'has-vp-speaker': !!turn.speakerVpId }">
|
|
673
673
|
<!-- 0. task-334-ui-b: VP speaker header \u2014 only when a speakerVpId is
|
|
674
674
|
bound AND the upstream consecutive-collapse decided this turn
|
|
@@ -867,7 +867,7 @@ ${String(e||"").trim()}
|
|
|
867
867
|
</button>
|
|
868
868
|
</div>
|
|
869
869
|
<pre><code${K}>${N}</code></pre>
|
|
870
|
-
</div>`}),R=W=>W.replace(/<table>([\s\S]*?)<\/table>/g,te=>`<div class="table-scroll-wrapper">${te}</div>`),B=W=>{if(!W)return"";typeof W!="string"&&(W=String(W));let te=K=>{let N=document.createElement("div");return N.textContent=K,N.innerHTML};return W.replace(/```(\w*)\n([\s\S]*?)```/g,(K,N,H)=>`<div class="code-block-wrapper"><pre><code class="language-${N}">${te(H.trim())}</code></pre></div>`).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")},O=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},j=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},ne=()=>{let W=e.turn.textContent||"";if(!W)return;let te=new Blob([W],{type:"text/markdown;charset=utf-8"}),K=URL.createObjectURL(te),N=document.createElement("a");N.download=`response-${Date.now()}.md`,N.href=K,N.click(),URL.revokeObjectURL(K)},ve=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let W=c.value;if(!W)return;let te=W.querySelector(".turn-content");if(!te)return;let K=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";te.classList.add("screenshot-mode");try{let H=te.getBoundingClientRect(),_=await window.htmlToImage.toPng(te,{backgroundColor:K,pixelRatio:3,width:H.width+64,height:H.height+64,style:{padding:"32px"},filter:se=>!(se.classList&&(se.classList.contains("turn-header")||se.classList.contains("screenshot-btn")))}),J=document.createElement("a");J.download=`response-${Date.now()}.png`,J.href=_,J.click()}finally{te.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(W){let K=W.closest(".code-block-wrapper").querySelector("code");if(K)try{await navigator.clipboard.writeText(K.textContent),W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>',setTimeout(()=>{W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>'},2e3)}catch{}}),Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})});let ue=W=>{if(W?.src)return W.src;if(!W?.fileId)return"";let te=W.previewToken||"";return`/api/preview/${W.fileId}?token=${te}`},be=W=>{d.add(W?.assetId||W?.id)},ie=(W,te)=>{let K=ue(W);K&&js(K,{alt:W?.filename||u("message.imagePreview"),closeLabel:u("common.close"),trigger:te})},Ce=W=>{if(W)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(W)}catch{}},x=()=>{let W=e.turn;return W?typeof W.timestamp=="number"&&W.timestamp>0?W.timestamp:typeof W.createdAt=="number"&&W.createdAt>0?W.createdAt:typeof W.speakerTimestamp=="number"&&W.speakerTimestamp>0?W.speakerTimestamp:null:null},Y=Vue.computed(()=>vt(x())),oe=Vue.computed(()=>{let W=x();if(!W)return"";try{return new Date(W).toLocaleString()}catch{return""}}),he=Vue.computed(()=>Nd(e.turn,e.quoteAuthor||u("message.assistant")));return{onStopTurn:Ce,turnTime:Y,turnTimeFull:oe,assistantQuote:he,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:b,latestTool:h,historyTools:A,latestToolIndex:w,actionTools:g,routeMessages:p,toolSummaryLabel:S,toggleExpand:m,toolExpandedValue:E,updateToolExpanded:V,textSegments:D,progressSegments:M,resultSegments:T,renderSegment:L,copyContent:O,copyFullResponse:j,exportMarkdown:ne,screenshotContent:ve,onAskSubmit:f,imageSrc:ue,failedImages:d,handleImageError:be,previewImage:ie,displayedTodos:y}}}});function Xu(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),n=t%60,r=String(n).padStart(2,"0");if(s<60)return`${s}:${r}`;let i=Math.floor(s/60),o=s%60;return`${i}:${String(o).padStart(2,"0")}:${r}`}var Zu=F(()=>{});var Ju,ep=F(()=>{oi();Br();Ws();Zu();
|
|
870
|
+
</div>`}),R=W=>W.replace(/<table>([\s\S]*?)<\/table>/g,te=>`<div class="table-scroll-wrapper">${te}</div>`),B=W=>{if(!W)return"";typeof W!="string"&&(W=String(W));let te=K=>{let N=document.createElement("div");return N.textContent=K,N.innerHTML};return W.replace(/```(\w*)\n([\s\S]*?)```/g,(K,N,H)=>`<div class="code-block-wrapper"><pre><code class="language-${N}">${te(H.trim())}</code></pre></div>`).replace(/`([^`]+)`/g,"<code>$1</code>").replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>").replace(/\*([^*]+)\*/g,"<em>$1</em>").replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\n/g,"<br>")},O=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch{}},j=async()=>{try{await navigator.clipboard.writeText(e.turn.textContent||""),r.value=!0,setTimeout(()=>{r.value=!1},2e3)}catch{}},ne=()=>{let W=e.turn.textContent||"";if(!W)return;let te=new Blob([W],{type:"text/markdown;charset=utf-8"}),K=URL.createObjectURL(te),N=document.createElement("a");N.download=`response-${Date.now()}.md`,N.href=K,N.click(),URL.revokeObjectURL(K)},ve=async()=>{if(!(l.value||!window.htmlToImage)){l.value=!0;try{let W=c.value;if(!W)return;let te=W.querySelector(".turn-content");if(!te)return;let K=getComputedStyle(document.body).getPropertyValue("--bg-main").trim()||"#ffffff";te.classList.add("screenshot-mode");try{let H=te.getBoundingClientRect(),_=await window.htmlToImage.toPng(te,{backgroundColor:K,pixelRatio:3,width:H.width+64,height:H.height+64,style:{padding:"32px"},filter:se=>!(se.classList&&(se.classList.contains("turn-header")||se.classList.contains("screenshot-btn")))}),J=document.createElement("a");J.download=`response-${Date.now()}.png`,J.href=_,J.click()}finally{te.classList.remove("screenshot-mode")}}catch{}finally{l.value=!1}}};Vue.onMounted(()=>{window.copyCodeBlock||(window.copyCodeBlock=async function(W){let K=W.closest(".code-block-wrapper").querySelector("code");if(K)try{await navigator.clipboard.writeText(K.textContent),W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/></svg>',setTimeout(()=>{W.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14"><path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>'},2e3)}catch{}}),Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})}),Vue.watch(()=>e.turn.textContent,()=>{Vue.nextTick(()=>{typeof hljs<"u"&&document.querySelectorAll("pre code:not([data-highlighted])").forEach(W=>{hljs.highlightElement(W),W.dataset.highlighted="true"}),Ye(c.value)})});let ue=W=>{if(W?.src)return W.src;if(!W?.fileId)return"";let te=W.previewToken||"";return`/api/preview/${W.fileId}?token=${te}`},be=W=>{d.add(W?.assetId||W?.id)},ie=(W,te)=>{let K=ue(W);K&&js(K,{alt:W?.filename||u("message.imagePreview"),closeLabel:u("common.close"),trigger:te})},Ce=W=>{if(W)try{typeof s.cancelVpTurn=="function"&&s.cancelVpTurn(W)}catch{}},x=()=>{let W=e.turn;return W?typeof W.timestamp=="number"&&W.timestamp>0?W.timestamp:typeof W.createdAt=="number"&&W.createdAt>0?W.createdAt:typeof W.speakerTimestamp=="number"&&W.speakerTimestamp>0?W.speakerTimestamp:null:null},Y=Vue.computed(()=>vt(x())),oe=Vue.computed(()=>{let W=x();if(!W)return"";try{return new Date(W).toLocaleString()}catch{return""}}),he=Vue.computed(()=>Nd(e.turn,e.quoteAuthor||u("message.assistant")));return{onStopTurn:Ce,turnTime:Y,turnTimeFull:oe,assistantQuote:he,copied:n,fullCopied:r,expanded:o,screenshotting:l,turnRef:c,showToolActions:b,latestTool:h,historyTools:A,latestToolIndex:w,actionTools:g,routeMessages:p,toolSummaryLabel:S,toggleExpand:m,toolExpandedValue:E,updateToolExpanded:V,textSegments:D,progressSegments:M,resultSegments:T,renderSegment:L,copyContent:O,copyFullResponse:j,exportMarkdown:ne,screenshotContent:ve,onAskSubmit:f,imageSrc:ue,failedImages:d,handleImageError:be,previewImage:ie,displayedTodos:y}}}});function Xu(e){if(!Number.isFinite(e)||e<0)return"";let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let s=Math.floor(t/60),n=t%60,r=String(n).padStart(2,"0");if(s<60)return`${s}:${r}`;let i=Math.floor(s/60),o=s%60;return`${i}:${String(o).padStart(2,"0")}:${r}`}var Zu=F(()=>{});var Ju,ep=F(()=>{oi();Br();Ws();Zu();cs();Ju={name:"VpTurnBlock",components:{AssistantTurn:Ks},props:{turn:{type:Object,required:!0},conversationId:{type:String,default:null},nowMs:{type:Number,default:0},responseCollapsible:{type:Boolean,default:!1},responseCollapsed:{type:Boolean,default:!1},responseToggleLabel:{type:String,default:""}},emits:["toggle-response-collapse","quote"],template:`
|
|
871
871
|
<div class="vp-turn-block"
|
|
872
872
|
:class="{ 'vp-turn-block-streaming': turn.isStreaming }"
|
|
873
873
|
:data-turn-id="turn.turnId || ''"
|
|
@@ -942,7 +942,7 @@ ${String(e||"").trim()}
|
|
|
942
942
|
/>
|
|
943
943
|
</div>
|
|
944
944
|
</div>
|
|
945
|
-
`,setup(e){let t=
|
|
945
|
+
`,setup(e){let t=fs(),s=yt(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(g=>g),i=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?s.vpLabel(g)||g:""}),o=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return!g||typeof s.vpTextColor!="function"?{}:{color:s.vpTextColor(g)}}),a=()=>{let g=e.turn&&e.turn.turnId;if(g)try{typeof t.cancelVpTurn=="function"&&t.cancelVpTurn(g)}catch{}},l=Vue.computed(()=>{let g=e.turn&&e.turn.speakerVpId;return g?t.isVpTypingInCurrentConv(g):!1}),c=Vue.computed(()=>!!(e.turn&&e.turn.isStreaming&&e.turn.turnId)),d=Vue.computed(()=>vt(e.turn.speakerTimestamp)),u=Vue.computed(()=>{let g=e.turn.speakerTimestamp;if(!g)return"";let b=new Date(g);return Number.isNaN(b.getTime())?"":b.toLocaleString()}),f=Vue.computed(()=>{let g=e.turn.speakerTimestamp;if(!g||!e.nowMs)return"";let b=e.nowMs-g;return b<0?"":Xu(b)}),p=Vue.computed(()=>{let g=e.turn&&e.turn.turnId,b=g?Object.values(t.activeVpTurns||{}).find(S=>S?.turnId===g&&(!t.currentAgent||!S?.agentId||S.agentId===t.currentAgent))||t.activeVpTurns?.[g]:null;if(!b?.retryAttempt||!b?.retryMax)return"";let h=b.retryRecoveryMode==="continue"?"yeaft.vp.turnBlock.retryingContinue":"yeaft.vp.turnBlock.retryingRequest",A=b.retryRecoveryMode==="continue"?`Response stalled; continuing with a fresh request (${b.retryAttempt}/${b.retryMax})`:`Response stalled; retrying with a fresh request (${b.retryAttempt}/${b.retryMax})`,w=r(h,{attempt:b.retryAttempt,max:b.retryMax});return w===h?A:w});return{onStopTurn:a,isTyping:l,showStop:c,displayName:i,speakerNameStyle:o,startedTimeText:d,startedTimeFullText:u,elapsedText:f,retryText:p}}}});function Rv(e){let t=[];if(typeof e!="string"||!e.trim())return t;let s=e.split(`
|
|
946
946
|
`),n=null;for(let r of s){let i=/^##\s+(.+?)\s*$/.exec(r);i?(n&&t.push(n),n={title:i[1],body:""}):n&&(n.body+=(n.body?`
|
|
947
947
|
`:"")+r)}n&&t.push(n);for(let r of t)r.body=r.body.trim();return t}var tp,sp=F(()=>{tp={name:"ReflectionCard",props:{card:{type:Object,required:!0}},data(){return{expanded:{"What was attempted":!1,"Key findings":!1,"Direction check":!0,"Suggested next direction":!1,"Tool execution log":!1}}},computed:{isPending(){return this.card&&this.card.status==="pending"},isError(){return this.card&&this.card.status==="error"},triggerLabel(){return this.card.trigger==="t1"?"In-turn reflection":"End-of-turn reflection"},sections(){let e=this.card&&this.card.content||"";return Rv(e)}},methods:{toggle(e){this.expanded={...this.expanded,[e]:!this.expanded[e]}}},template:`
|
|
948
948
|
<div class="reflection-card" :class="{ 'is-pending': isPending, 'is-error': isError }">
|
|
@@ -1015,7 +1015,7 @@ ${String(e||"").trim()}
|
|
|
1015
1015
|
/>
|
|
1016
1016
|
</div>
|
|
1017
1017
|
</div>
|
|
1018
|
-
`}});function Bn(e,t,s){return Math.min(Math.max(e,t),s)}function ai(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+ai(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+ai(s),0):String(e).length:0}function ap(e){if(!e)return 260;let t=ai(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return Bn(110+Math.ceil(t/90)*18+s*120,120,1400)}function _v(e){if(!e)return 260;let t=ai(e.text||e.content||""),s=Array.isArray(e.toolMsgs)?e.toolMsgs.length:0,n=Array.isArray(e.images)?e.images.length:0,r=Array.isArray(e.askRequests)?e.askRequests.length:0;return Bn(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function jt(e){if(!e)return 260;if(e.type==="message-block"){let t=Array.isArray(e.items)?e.items:[];return t.length?t.reduce((s,n)=>s+jt(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?_v(e):e.message?ap(e.message):ap(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function Ev(e,t,s,n){let r=Ys(e,t),i=s instanceof Map?s.get(r):s?.[r];if(Number.isFinite(i)&&i>0)return i;let o=n?n(e,t):jt(e);return Number.isFinite(o)&&o>0?o:260}function Ra(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||jt,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=Ev(n[l],l,t,i);a.push(c),o.push(o[l]+c+(l<n.length-1?r:0))}return{offsets:o,heights:a,totalHeight:o[o.length-1]||0,itemGap:r}}function lp(e,t){let s=0,n=Math.max(0,e.length-2),r=0;for(;s<=n;){let i=Math.floor((s+n)/2);e[i+1]<=t?(r=i+1,s=i+1):n=i-1}return r}function Dv(e,t,s){let n=lp(e,t);for(;n<s&&e[n]<t;)n+=1;return Bn(n,0,s)}function cp(e,t,s={}){let n=Array.isArray(e)?e:[],r=n.length;if(!r)return{start:0,end:0,visibleStart:0,visibleEnd:0,topSpacerHeight:0,bottomSpacerHeight:0,totalHeight:0,items:[]};let i=Math.max(0,Number(s.scrollTop||0)),o=Math.max(1,Number(s.viewportHeight||720)),a=Math.max(0,Number(s.overscan??1)),l=Array.isArray(t?.offsets)?t.offsets:[0],c=Number.isFinite(t?.totalHeight)?t.totalHeight:0,d=i+o,u=Bn(lp(l,i),0,r-1),f=Bn(Dv(l,d,r),u+1,r),p=Math.max(0,u-a),g=Math.min(r,f+a);return{start:p,end:g,visibleStart:u,visibleEnd:f,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[g]||c)),totalHeight:c,items:n.slice(p,g).map((b,h)=>{let A=p+h;return{item:b,index:A,key:Ys(b,A),top:l[A]||0}})}}function dp(e,t,s={},n={}){let r=Array.isArray(e)?e:[],i=Math.max(0,Math.min(r.length-1,Number.isFinite(t)?Math.floor(t):0));if(r.length===0)return 0;let{offsets:o,heights:a,totalHeight:l}=Ra(r,s,n),c=Math.max(1,Number(n.viewportHeight||720)),d=n.align==="start"||n.align==="end"?n.align:"center",u=o[i]||0,f=a[i]||260;return d==="start"?Math.max(0,Math.min(u,l-c)):d==="end"?Math.max(0,Math.min(u+f-c,l-c)):Math.max(0,Math.min(u-(c-f)/2,l-c))}function
|
|
1018
|
+
`}});function Bn(e,t,s){return Math.min(Math.max(e,t),s)}function ai(e){return e?typeof e=="string"?e.length:Array.isArray(e)?e.reduce((t,s)=>t+ai(s),0):typeof e=="object"?Object.values(e).reduce((t,s)=>t+ai(s),0):String(e).length:0}function ap(e){if(!e)return 260;let t=ai(e.content||e.text||e.message||""),s=Array.isArray(e.attachments)?e.attachments.length:0;return Bn(110+Math.ceil(t/90)*18+s*120,120,1400)}function _v(e){if(!e)return 260;let t=ai(e.text||e.content||""),s=Array.isArray(e.toolMsgs)?e.toolMsgs.length:0,n=Array.isArray(e.images)?e.images.length:0,r=Array.isArray(e.askRequests)?e.askRequests.length:0;return Bn(160+Math.ceil(t/95)*18+s*56+n*140+r*96,160,1400)}function jt(e){if(!e)return 260;if(e.type==="message-block"){let t=Array.isArray(e.items)?e.items:[];return t.length?t.reduce((s,n)=>s+jt(n),0)+Math.max(0,t.length-1)*18:260}return e.type==="assistant-turn"?_v(e):e.message?ap(e.message):ap(e)}function Ys(e,t=0){return String(e?.id||e?.messageId||e?.turnId||`virtual_${t}`)}function Ev(e,t,s,n){let r=Ys(e,t),i=s instanceof Map?s.get(r):s?.[r];if(Number.isFinite(i)&&i>0)return i;let o=n?n(e,t):jt(e);return Number.isFinite(o)&&o>0?o:260}function Ra(e,t={},s={}){let n=Array.isArray(e)?e:[],r=Math.max(0,Number(s.itemGap??18)),i=s.estimateHeight||jt,o=[0],a=[];for(let l=0;l<n.length;l+=1){let c=Ev(n[l],l,t,i);a.push(c),o.push(o[l]+c+(l<n.length-1?r:0))}return{offsets:o,heights:a,totalHeight:o[o.length-1]||0,itemGap:r}}function lp(e,t){let s=0,n=Math.max(0,e.length-2),r=0;for(;s<=n;){let i=Math.floor((s+n)/2);e[i+1]<=t?(r=i+1,s=i+1):n=i-1}return r}function Dv(e,t,s){let n=lp(e,t);for(;n<s&&e[n]<t;)n+=1;return Bn(n,0,s)}function cp(e,t,s={}){let n=Array.isArray(e)?e:[],r=n.length;if(!r)return{start:0,end:0,visibleStart:0,visibleEnd:0,topSpacerHeight:0,bottomSpacerHeight:0,totalHeight:0,items:[]};let i=Math.max(0,Number(s.scrollTop||0)),o=Math.max(1,Number(s.viewportHeight||720)),a=Math.max(0,Number(s.overscan??1)),l=Array.isArray(t?.offsets)?t.offsets:[0],c=Number.isFinite(t?.totalHeight)?t.totalHeight:0,d=i+o,u=Bn(lp(l,i),0,r-1),f=Bn(Dv(l,d,r),u+1,r),p=Math.max(0,u-a),g=Math.min(r,f+a);return{start:p,end:g,visibleStart:u,visibleEnd:f,topSpacerHeight:l[p]||0,bottomSpacerHeight:Math.max(0,c-(l[g]||c)),totalHeight:c,items:n.slice(p,g).map((b,h)=>{let A=p+h;return{item:b,index:A,key:Ys(b,A),top:l[A]||0}})}}function dp(e,t,s={},n={}){let r=Array.isArray(e)?e:[],i=Math.max(0,Math.min(r.length-1,Number.isFinite(t)?Math.floor(t):0));if(r.length===0)return 0;let{offsets:o,heights:a,totalHeight:l}=Ra(r,s,n),c=Math.max(1,Number(n.viewportHeight||720)),d=n.align==="start"||n.align==="end"?n.align:"center",u=o[i]||0,f=a[i]||260;return d==="start"?Math.max(0,Math.min(u,l-c)):d==="end"?Math.max(0,Math.min(u+f-c,l-c)):Math.max(0,Math.min(u-(c-f)/2,l-c))}function gs({scrollTop:e=0,scrollHeight:t=0,clientHeight:s=0,threshold:n=80}={}){return Math.max(0,Number(t)-Number(e)-Number(s))<=Math.max(0,Number(n))}function up(e=0,{viewports:t=2,minPx:s=600}={}){let n=Math.max(0,Number(e)||0),r=Math.max(0,Number(t)||0);return Math.max(0,Number(s)||0,n*r)}function pp({following:e=!0,atBottom:t=!1,userScroll:s=!1}={}){return(s||!!e)&&!!t}function fp({following:e=!0,atBottom:t=!1,resumeBoundaryReached:s=!1,direction:n=0}={}){let r=Number(n)||0;return r<0?!1:e?!!t:r>0&&!!s}function Vv(e){return Lv.has(String(e||""))}function gp(e,t){if(!e||!t||e.button!==0)return!1;let s=t.getBoundingClientRect?.(),n=Math.max(0,Number(t.offsetWidth||0)-Number(t.clientWidth||0));return!s||n<=0?!1:Number(e.clientX)>=Number(s.right)-n&&Number(e.clientX)<=Number(s.right)&&Number(e.clientY)>=Number(s.top)&&Number(e.clientY)<=Number(s.bottom)}function mp(e,t,s=globalThis.document){if(!e||e.defaultPrevented||!t||!Vv(e.key))return!1;let n=e.target;return!n||n.closest?.($v)?!1:n===t||n===s?.body||n===s?.documentElement}var Lv,$v,_t,_a=F(()=>{Lv=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]),$v='input, textarea, select, button, a, [contenteditable], [role="button"], [role="link"]';_t=Object.freeze({itemHeight:260,viewportHeight:720,overscan:1,itemGap:18,bottomThreshold:80,resumeBottomThreshold:2,historyPrefetchViewports:2,historyPrefetchMinPx:600})});var Wn,hp,vp=F(()=>{_a();Wn=2,hp={name:"VirtualTranscript",props:{items:{type:Array,default:()=>[]},overscan:{type:Number,default:_t.overscan},itemGap:{type:Number,default:_t.itemGap},estimateHeight:{type:Function,default:jt},initialAlign:{type:String,default:"start"}},emits:["scroll-state"],template:`
|
|
1019
1019
|
<div class="virtual-transcript" ref="rootRef">
|
|
1020
1020
|
<div
|
|
1021
1021
|
v-if="topSpacerHeight > 0"
|
|
@@ -1042,8 +1042,8 @@ ${String(e||"").trim()}
|
|
|
1042
1042
|
aria-hidden="true"
|
|
1043
1043
|
></div>
|
|
1044
1044
|
</div>
|
|
1045
|
-
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=e.initialAlign==="end",o=Vue.ref(i?Number.MAX_SAFE_INTEGER:0),a=Vue.ref(_t.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,f=null,p=null,g=null,b=null,h=0,A=!1,w=0,S=!0,y=null,m="start",v=null,E=Vue.computed(()=>Ra(e.items,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight})),V=Vue.computed(()=>cp(e.items,E.value,{scrollTop:o.value,viewportHeight:a.value,overscan:e.overscan})),U=Vue.computed(()=>V.value.items),L=Vue.computed(()=>V.value.topSpacerHeight),D=Vue.computed(()=>V.value.bottomSpacerHeight);function M(K){K&&t("scroll-state",{scrollTop:K.scrollTop||0,scrollHeight:K.scrollHeight||0,clientHeight:K.clientHeight||0})}function T(){let K=r.value;K&&(a.value=Math.max(1,K.clientHeight||_t.viewportHeight),i&&e.items.length===0||(o.value=Math.max(0,K.scrollTop||0)),M(K))}function C(){let K=r.value;return!i||e.initialAlign!=="end"||e.items.length===0||!K?!1:(ne(),K.scrollTop=K.scrollHeight,i=!1,T(),!0)}function R(){C()||T()}function B(){p||(p=requestAnimationFrame(()=>{p=null,T()}))}function O(K){return K?
|
|
1046
|
-
`),()=>{c.clear(),e.items.forEach((K,N)=>c.set(Ys(K,N),N)),y&&!c.has(y)&&ne(),Vue.nextTick(R)},{immediate:!0}),Vue.onMounted(()=>{if(r.value=n.value?.closest?.(".chat-container")||n.value?.parentElement||null,R(),r.value?.addEventListener("scroll",B,{passive:!0}),window.addEventListener("resize",B),typeof ResizeObserver<"u"){f=new ResizeObserver(K=>{for(let N of K){let H=N.target?.dataset?.virtualId,_=Number(N.target?.dataset?.virtualIndex);H&&ue(H,_,N.target)}});for(let[K,N]of d.entries()){let H=c.get(K)??Number(N.dataset?.virtualIndex||0);Y(K,H,N)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",B),window.removeEventListener("resize",B),f&&f.disconnect(),p&&cancelAnimationFrame(p),g&&cancelAnimationFrame(g),b&&cancelAnimationFrame(b),u.clear(),h=0,A=!1}),{rootRef:n,visibleEntries:U,topSpacerHeight:L,bottomSpacerHeight:D,setItemRef:oe}}}});function Un(e){return typeof e=="string"&&e.trim()?e.trim():""}function Fv(e){return Un(e?.speakerVpId)||Un(e?.vpId)}function yp(e,t){if(!e||!t)return!1;let s=Un(e.speakerVpId),n=Fv(t);if(s&&n&&s!==n)return!0;if(e.isHistory&&t.isHistory)return!1;let r=Un(e.turnId),i=Un(t.turnId);return!!(r&&i&&r!==i)}var bp=F(()=>{});function jn(e){return e?e.type!=="user"&&e.type!=="system"&&e.type!=="error":!1}function li(e){let t=Array.isArray(e?.items)?e.items:[];return e?.responseCollapsed?t.filter(s=>!jn(s)):t}function Ov(e){return(Array.isArray(e?.items)?e.items:[]).filter(jn)}function wp(e){let t=Ov(e);return t.length?t[0]:null}function Hv(e){let t=e?.textContent??e?.text??e?.content??e?.message?.content??"";return typeof t=="string"?t:Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&s.type==="text"&&s.text||"").join(""):t==null?"":String(t)}function kp(e){if(!e?.responseCollapsed)return[];let t=wp(e);return Hv(t).replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[[^\]]*\]\(([^)]*)\)/g,"").replace(/[#>*_~\-]+/g," ").split(/\r?\n/).map(n=>n.trim()).filter(Boolean).slice(0,2)}function Sp(e,t){if(!e?.responseCollapsed||typeof t!="function")return null;let s=li(e),n=wp(e)?74:0,r=s.length+(n?1:0);if(!s.length)return n;let i=s.reduce((a,l)=>a+t(l),0),o=Math.max(0,r-1)*18;return i+o+n}var Ip=F(()=>{});function
|
|
1045
|
+
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=e.initialAlign==="end",o=Vue.ref(i?Number.MAX_SAFE_INTEGER:0),a=Vue.ref(_t.viewportHeight),l=Vue.reactive({}),c=new Map,d=new Map,u=new Map,f=null,p=null,g=null,b=null,h=0,A=!1,w=0,S=!0,y=null,m="start",v=null,E=Vue.computed(()=>Ra(e.items,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight})),V=Vue.computed(()=>cp(e.items,E.value,{scrollTop:o.value,viewportHeight:a.value,overscan:e.overscan})),U=Vue.computed(()=>V.value.items),L=Vue.computed(()=>V.value.topSpacerHeight),D=Vue.computed(()=>V.value.bottomSpacerHeight);function M(K){K&&t("scroll-state",{scrollTop:K.scrollTop||0,scrollHeight:K.scrollHeight||0,clientHeight:K.clientHeight||0})}function T(){let K=r.value;K&&(a.value=Math.max(1,K.clientHeight||_t.viewportHeight),i&&e.items.length===0||(o.value=Math.max(0,K.scrollTop||0)),M(K))}function C(){let K=r.value;return!i||e.initialAlign!=="end"||e.items.length===0||!K?!1:(ne(),K.scrollTop=K.scrollHeight,i=!1,T(),!0)}function R(){C()||T()}function B(){p||(p=requestAnimationFrame(()=>{p=null,T()}))}function O(K){return K?gs({scrollTop:K.scrollTop,scrollHeight:K.scrollHeight,clientHeight:K.clientHeight,threshold:_t.bottomThreshold}):!0}function j({delta:K=0,toBottom:N=!1}={},H=w){if(H!==w||(Math.abs(K)>=Wn&&(h+=K),N&&(A=!0),b))return;let _=H;b=requestAnimationFrame(()=>{if(b=null,_!==w)return;let J=r.value;if(!J){h=0,A=!1;return}A?J.scrollTop=J.scrollHeight:Math.abs(h)>=Wn&&(J.scrollTop+=h),h=0,A=!1,T()})}function ne(){y=null,v=null}function ve({preserveTarget:K=!1}={}){w+=1,A=!1,h=0,K||ne(),b&&cancelAnimationFrame(b),b=null}function ue(K,N,H){!K||!H||(u.set(K,{index:N,el:H}),!g&&(g=requestAnimationFrame(()=>{g=null;let _=Array.from(u.entries());u.clear(),be(_)})))}function be(K){let N=[];for(let[fe,ae]of K){let De=ae?.el;if(!De)continue;let $e=Math.ceil(De.getBoundingClientRect?.().height||De.offsetHeight||0);if(!Number.isFinite($e)||$e<=0)continue;let Oe=l[fe];if(Oe===$e)continue;let je=c.get(fe);N.push({key:fe,nextHeight:$e,previousHeight:Oe,itemIndex:Number.isFinite(je)?je:ae.index})}if(!N.length)return;let H=r.value,_=S&&O(H),J=V.value.visibleStart,se=!!y&&N.some(fe=>fe.key===y),me=0,z=!1;for(let fe of N){let{key:ae,nextHeight:De,previousHeight:$e,itemIndex:Oe}=fe;if(l[ae]=De,!H||!Number.isFinite($e))continue;let je=De-$e;Math.abs(je)<Wn||(Number.isFinite(Oe)&&Oe<J?me+=je:_&&(z=!0))}if(se){ve({preserveTarget:!0}),Ce(y,m);return}if(Math.abs(me)>=Wn||z){let fe={delta:me,toBottom:z},ae=w;z?Vue.nextTick(()=>j(fe,ae)):j(fe,ae)}}function ie(K,N="start"){let H=r.value,_=v||d.get(String(K));if(!H||!_)return!1;let J=H.getBoundingClientRect?.(),se=_.getBoundingClientRect?.();if(!J||!se)return!1;let me=Number(J.top),z=Number(H.clientHeight||a.value),ee=Number(se.height||0),fe=N==="center"&&ee<=z?me+(z-ee)/2:N==="end"&&ee<=z?Number(J.bottom)-ee:me,ae=Number(se.top)-fe;return Math.abs(ae)>=Wn&&(H.scrollTop+=ae),T(),!0}function Ce(K,N="start",H){let _=String(K);y=_,m=N,H!==void 0&&(v=H);let J=()=>{y===_&&ie(_,m)};Vue.nextTick(J)}function x(K){let N=!!K;N&&ne(),S!==N&&(S=N,S||ve())}function Y(K,N,H){c.set(K,N),H&&(d.set(K,H),f&&f.observe(H),Vue.nextTick(()=>ue(K,N,H)))}function oe(K,N,H){if(!K)return;let _=d.get(K);if(_&&_!==H&&f&&f.unobserve(_),!H){d.delete(K);return}Y(K,N,H)}async function he(K,{align:N="center"}={}){let H=Number.isFinite(K)?Math.floor(K):-1,_=r.value;if(!_||H<0||H>=e.items.length)return!1;ve({preserveTarget:!0});let J=Ys(e.items[H],H);return y=J,m=N,v=null,_.scrollTop=dp(e.items,H,l,{itemGap:e.itemGap,estimateHeight:e.estimateHeight,viewportHeight:_.clientHeight||a.value,align:N}),T(),await Vue.nextTick(),d.get(J)?(Ce(J,N),!0):!1}function W(K,N={}){let H=c.get(String(K));return Number.isFinite(H)?he(H,N):Promise.resolve(!1)}function te(K,N,{align:H="start"}={}){let _=String(K||"");return!_||!N?!1:(y=_,m=H,v=N,ie(_,H),!0)}return s({scrollToKey:W,scrollToIndex:he,anchorTarget:te,clearTargetAnchor:ne,cancelPendingBottomFollow:ve,setBottomFollowEnabled:x}),Vue.watch(()=>e.items.map((K,N)=>Ys(K,N)).join(`
|
|
1046
|
+
`),()=>{c.clear(),e.items.forEach((K,N)=>c.set(Ys(K,N),N)),y&&!c.has(y)&&ne(),Vue.nextTick(R)},{immediate:!0}),Vue.onMounted(()=>{if(r.value=n.value?.closest?.(".chat-container")||n.value?.parentElement||null,R(),r.value?.addEventListener("scroll",B,{passive:!0}),window.addEventListener("resize",B),typeof ResizeObserver<"u"){f=new ResizeObserver(K=>{for(let N of K){let H=N.target?.dataset?.virtualId,_=Number(N.target?.dataset?.virtualIndex);H&&ue(H,_,N.target)}});for(let[K,N]of d.entries()){let H=c.get(K)??Number(N.dataset?.virtualIndex||0);Y(K,H,N)}}}),Vue.onBeforeUnmount(()=>{r.value?.removeEventListener("scroll",B),window.removeEventListener("resize",B),f&&f.disconnect(),p&&cancelAnimationFrame(p),g&&cancelAnimationFrame(g),b&&cancelAnimationFrame(b),u.clear(),h=0,A=!1}),{rootRef:n,visibleEntries:U,topSpacerHeight:L,bottomSpacerHeight:D,setItemRef:oe}}}});function Un(e){return typeof e=="string"&&e.trim()?e.trim():""}function Fv(e){return Un(e?.speakerVpId)||Un(e?.vpId)}function yp(e,t){if(!e||!t)return!1;let s=Un(e.speakerVpId),n=Fv(t);if(s&&n&&s!==n)return!0;if(e.isHistory&&t.isHistory)return!1;let r=Un(e.turnId),i=Un(t.turnId);return!!(r&&i&&r!==i)}var bp=F(()=>{});function jn(e){return e?e.type!=="user"&&e.type!=="system"&&e.type!=="error":!1}function li(e){let t=Array.isArray(e?.items)?e.items:[];return e?.responseCollapsed?t.filter(s=>!jn(s)):t}function Ov(e){return(Array.isArray(e?.items)?e.items:[]).filter(jn)}function wp(e){let t=Ov(e);return t.length?t[0]:null}function Hv(e){let t=e?.textContent??e?.text??e?.content??e?.message?.content??"";return typeof t=="string"?t:Array.isArray(t)?t.map(s=>typeof s=="string"?s:s&&s.type==="text"&&s.text||"").join(""):t==null?"":String(t)}function kp(e){if(!e?.responseCollapsed)return[];let t=wp(e);return Hv(t).replace(/```[\s\S]*?```/g," ").replace(/`([^`]+)`/g,"$1").replace(/!\[[^\]]*\]\([^)]*\)/g," ").replace(/\[[^\]]*\]\(([^)]*)\)/g,"").replace(/[#>*_~\-]+/g," ").split(/\r?\n/).map(n=>n.trim()).filter(Boolean).slice(0,2)}function Sp(e,t){if(!e?.responseCollapsed||typeof t!="function")return null;let s=li(e),n=wp(e)?74:0,r=s.length+(n?1:0);if(!s.length)return n;let i=s.reduce((a,l)=>a+t(l),0),o=Math.max(0,r-1)*18;return i+o+n}var Ip=F(()=>{});function ms(e,t){typeof t!="string"||!/^m\d+$/.test(t)||e.includes(t)||e.push(t)}function qv(e){if(!e)return[];let t=[];for(let s of Array.isArray(e.messages)?e.messages:[])ms(t,s?.id),ms(t,s?.messageId),ms(t,s?.persistedMessageId);return ms(t,e.message?.id),ms(t,e.messageId),ms(t,e.atMessageId),e.type!=="assistant-turn"&&ms(t,e.id),t}function Cp(e){return!e?.closest?.(".yeaft-conversation-outline, .yeaft-conversation-outline-sender-menu, .yeaft-search-btn")}async function Ap({result:e,revealWindow:t,nextTick:s,revealMessage:n,isMobile:r,closeOutline:i}){if(!e||!await t?.(e))return!1;await s?.();let a=await n?.(e.messageId);return a&&r&&i?.(),!!a}function Nv(e,t){if(!t)return null;for(let s of Array.isArray(e)?e:[]){if(!s)continue;let n=Array.isArray(s.items)?s.items:[s];for(let r of n){if(!qv(r).includes(t))continue;let i=r?.id,o=s?.id;return!i||!o?null:{blockId:o,rowId:i,collapseKey:s.responseCollapseKey||null,requiresExpansion:!!(s.responseCollapsed&&r.type==="assistant-turn")}}}return null}async function xp({blocks:e,messageId:t,collapseStates:s,scrollToBlock:n,findRow:r,anchorRow:i,flashRow:o,nextTick:a,align:l="start"}){let c=Nv(e,t);if(!c||typeof n!="function"||typeof r!="function")return!1;if(c.requiresExpansion){if(!c.collapseKey||!s)return!1;s[c.collapseKey]=!1,await a?.()}if(!await n(c.blockId,{align:l}))return!1;await a?.();let u=r(c.rowId);return u?(typeof i=="function"?i(c.blockId,c.rowId,u,{align:l}):u.scrollIntoView?.({block:l,inline:"nearest"}),o?.(c.rowId),!0):!1}var Ea=F(()=>{});var ci,Da=F(()=>{ct();ya();ti();oi();ep();Ma();sp();rp();op();vp();bp();_a();Ip();Ea();cs();Vr();ci={name:"MessageList",components:{MessageItem:zs,AssistantTurn:Ks,VpTurnBlock:Ju,VpSpeakerHeader:ri,ReflectionCard:tp,SubAgentCard:np,UserTurnBlock:ip,VirtualTranscript:hp},template:`
|
|
1047
1047
|
<main class="chat-container" ref="containerRef">
|
|
1048
1048
|
<!-- Session Loading Overlay - only covers message area -->
|
|
1049
1049
|
<div class="session-loading-overlay" v-if="showSessionLoadingOverlay">
|
|
@@ -1665,7 +1665,7 @@ ${String(e||"").trim()}
|
|
|
1665
1665
|
{{ $t('message.scrollToLatest') }}
|
|
1666
1666
|
</button>
|
|
1667
1667
|
</main>
|
|
1668
|
-
`,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=_e(),r=typeof window<"u"&&window.Pinia?.useVpStore?window.Pinia.useVpStore():null,i=Vue.inject("t",null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.reactive({}),c=Vue.reactive({}),d=Vue.reactive({}),u=k=>String(k?.id||k?.turnId||k?.messageId||k?.atMessageId||k?.message?.id||"turn_unknown"),f=k=>{let $=u(k);return Object.prototype.hasOwnProperty.call(l,$)?!!l[$]:!1},p=(k,$)=>{l[u(k)]=!!$},g=({key:k,value:$}={})=>{k&&(c[k]=!!$)},b=k=>{let $=Sp(k,jt);return Number.isFinite($)?$:jt(k)},h=k=>li(k),A=k=>{let $=Array.isArray(k?.collapsedResponsePreview)?k.collapsedResponsePreview:kp(k);return Array.isArray($)?$:$?[String($)]:[]},w=k=>{let $=Array.isArray(k?.items)?k.items.find(we=>jn(we)):null,q=$?.speakerVpId||$?.vpId||$?.message?.speakerVpId||$?.message?.vpId||k?.vpId||"",pe=q&&r&&typeof r.vpLabel=="function"?r.vpLabel(q)||q:q||(typeof i=="function"?i("message.assistant"):"Assistant"),ke=q&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(q)}:{},re=$?.speakerTimestamp||$?.timestamp||$?.createdAt||$?.message?.timestamp||$?.message?.createdAt||0,Ve="",Ue="";if(re)try{let we=new Date(re);Number.isNaN(we.getTime())||(Ve=vt(re),Ue=we.toLocaleString())}catch{}return{name:pe,style:ke,timeText:Ve,fullTimeText:Ue}},S=k=>{let $=Array.isArray(k?.items)?k.items:[];for(let q=$.length-1;q>=0;q-=1)if(jn($[q]))return $[q];return null},y=(k,$)=>!k?.responseCollapsible||!$?!1:S(k)===$,m=k=>!!(k?.responseCollapsible&&!li(k).some($=>y(k,$))),v=k=>{let $=k?.responseCollapseKey;$&&(d[$]=!k.responseCollapsed)},E=k=>{let $=Number(k?.responseCount||0),q=k?.responseCollapsed?"message.showResponses":"message.hideResponses",pe=(typeof i=="function"?i(q):"")||(k?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(pe).replace("{count}",String($))},V=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),U=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let k=V();if(!k)return null;let $=s.yeaftActiveSessionFilter||null;return $&&typeof k.sessionById=="function"&&k.sessionById($,s.currentAgent||null)?$:k.activeSessionId&&typeof k.sessionById=="function"&&k.sessionById(k.activeSessionId,s.currentAgent||null)?k.activeSessionId:null}),L=Vue.computed(()=>{let k=s.currentView||"",$=s.currentAgent||"";if(k==="yeaft"){let q=s.yeaftActiveSessionFilter||U.value||"__all__";return[k,$,q].join("")}return[k,$,s.activeConversationId||""].join("")}),D=Vue.computed(()=>U.value!==null),M=Vue.computed(()=>s.agents.filter(k=>k.online)),T=Vue.ref(null),C=Vue.ref(null),R=Vue.ref(!1),B=Vue.ref(""),O=null,j=0,ne=n.token||"",ve=()=>{T.value=null,C.value=null,B.value="",O=null,j+=1},ue=Xr(),be=Zr(),ie=Vue.computed(()=>Jr({profile:T.value,agentSecret:C.value,serverWsUrl:On(location)})),Ce=()=>{let k={"Content-Type":"application/json"};return n.token&&(k.Authorization=`Bearer ${n.token}`),k},x=async()=>{if(M.value.length>0||s.currentConversation)return;if(C.value||O)return O;R.value=!0,B.value="";let k=++j;return O=(async()=>{let $=n.token||"",q=Ce(),[pe,ke]=await Promise.all([fetch("/api/user/profile",{headers:q}),fetch("/api/user/agent-secret",{headers:q})]),re=pe.ok?await pe.json():null;if(k!==j||$!==(n.token||""))return;if(re&&(T.value=re),!ke.ok){let we="";try{we=(await ke.json())?.error||""}catch{}throw new Error(we||"Failed to load Agent secret")}let Ve=await ke.json();if(k!==j||$!==(n.token||""))return;let Ue=Ve?.agentSecret||Ve?.agent_secret||null;C.value=Ue&&String(Ue).trim()?String(Ue):null})().catch($=>{k===j&&(B.value=$?.message||"Failed to load Agent secret")}).finally(()=>{k===j&&(R.value=!1,O=null)}),O},Y=async k=>{if(k)try{await navigator.clipboard.writeText(k)}catch{}},oe=(k,$)=>{let q=k?.message||null,pe=k?.id||k?.atMessageId||q?.id||q?.messageId||`legacy_${$}`,ke=k?.speakerVpId||k?.vpId||q?.speakerVpId||q?.vpId||"";return{id:`message_${ke||"user"}_${pe}_${$}`,vpId:ke,messageId:pe}},he=Vue.computed(()=>{let k=s.messages,$=[],q=null,pe=0,ke=()=>{if(q){q.isActive=!!(q.turnId&&Object.values(s.activeVpTurns||{}).some(Qe=>((Qe?.turnId||null)===q.turnId||!Qe?.turnId&&s.activeVpTurns?.[q.turnId]===Qe)&&(!s.currentAgent||!Qe?.agentId||Qe.agentId===s.currentAgent))),$r(q);let we=!!(q.textContent||q.todoMsg||q.askMsg||q.imageMsgs.length>0),ce=q.toolMsgs.length>0||q.toolSummaryCount>0;(we||ce)&&(q.showSpeakerHeader=!!q.speakerVpId,$.push(q)),q=null}},re=we=>{if(q){if(!q.speakerVpId){let ce=we.speakerVpId||we.vpId;ce&&(q.speakerVpId=ce,q.speakerTimestamp=typeof we.timestamp=="number"&&we.timestamp>0?we.timestamp:typeof we.createdAt=="number"?we.createdAt:0,typeof we.lastStateChangeCause=="string"&&!q.speakerStateCause&&(q.speakerStateCause=we.lastStateChangeCause))}!q.turnId&&we.turnId&&(q.turnId=we.turnId)}},Ve=()=>{pe++,q={type:"assistant-turn",id:"turn_"+pe,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,turnId:null}},Ue=we=>{yp(q,we)&&ke()};for(let we=0;we<k.length;we++){let ce=k[we];if(ce.type==="user"){if(!ce.content||!ce.content.trim())continue;ke(),$.push({type:"user",id:ce.id||"u_"+we,message:ce});continue}if(ce.type==="system"||ce.type==="error"){ke(),$.push({type:ce.type,id:ce.id||"s_"+we,message:ce});continue}if(!(ce.type==="tool-result"||ce.type==="tool_result")){if(ce.type==="tool-summary"){Ue(ce),q||Ve(),re(ce),ce.isHistory&&(q.isHistory=!0),q.toolSummaryCount+=Number(ce.count||ce.omittedCount||0)||0,q.messages.push(ce);continue}if(ce.type==="assistant"){Ue(ce),q||Ve(),Lr(q,ce),ce.isStreaming&&(q.isStreaming=!0),ce.isHistory&&(q.isHistory=!0),ce.id&&/^m\d+$/.test(ce.id)&&(q.atMessageId=ce.id),re(ce),q.messages.push(ce);continue}if(ce.type==="tool-use"){Ue(ce),q||Ve(),re(ce);let Qe=k[we+1],Ts=Qe&&(Qe.type==="tool-result"||Qe.type==="tool_result"),un={...ce,hasResult:Ts||ce.hasResult||!1,toolResult:ce.toolResult||null};ce.isHistory&&(q.isHistory=!0),ce.toolName==="TodoWrite"?q.todoMsg=un:ce.toolName==="AskUserQuestion"?q.askMsg=un:q.toolMsgs.push(un),q.messages.push(ce);continue}if(ce.type==="chat-image"){Ue(ce),q||Ve(),re(ce),ce.isHistory&&(q.isHistory=!0),q.imageMsgs.push(ce),q.messages.push(ce);continue}ke(),$.push({type:ce.type||"unknown",id:ce.id||"x_"+we,message:ce})}}return ke(),$}),W=Vue.computed(()=>{let k=[],$=null,q=()=>{$&&k.push($),$=null};return he.value.forEach((pe,ke)=>{if(!pe||pe.type==="system"||pe.type==="error"){q(),k.push(pe);return}let re=oe(pe,ke);if(pe.type==="user"||!$){q(),$={type:"message-block",id:`turn_${re.messageId}_${ke}`,vpId:re.vpId,messageId:re.messageId,items:[pe]};return}$.items.push(pe),!$.vpId&&re.vpId&&($.vpId=re.vpId)}),q(),k}),te=Vue.computed(()=>{let k=s.yeaftReflectionCards||{},$=s.yeaftConversationId,q={__orphans:[]},pe=Object.values(k).filter(re=>re&&re.conversationId===$).sort((re,Ve)=>(re.anchorOrder||0)-(Ve.anchorOrder||0)||(re.updatedAt||0)-(Ve.updatedAt||0)),ke=new Set;for(let re of s.messages||[])re&&re.id&&ke.add(re.id);for(let re of pe)re.anchorMsgId&&ke.has(re.anchorMsgId)?(q[re.anchorMsgId]||(q[re.anchorMsgId]=[]),q[re.anchorMsgId].push(re)):q.__orphans.push(re);return q}),K=k=>k?k.type==="assistant-turn"?k.atMessageId||null:k.message&&k.message.id||null:null,N=k=>{let $=K(k);return $?(te.value||{})[$]||[]:[]},H=Vue.computed(()=>(te.value||{}).__orphans||[]),_=Vue.computed(()=>{let k=s.yeaftSubAgentCards||{},$=s.yeaftConversationId,q={__orphans:[]},pe=Object.values(k).filter(re=>re&&re.conversationId===$).sort((re,Ve)=>(re.anchorOrder||0)-(Ve.anchorOrder||0)||(re.updatedAt||0)-(Ve.updatedAt||0)),ke=new Set;for(let re of s.messages||[])re&&re.id&&ke.add(re.id);for(let re of pe)re.anchorMsgId&&ke.has(re.anchorMsgId)?(q[re.anchorMsgId]||(q[re.anchorMsgId]=[]),q[re.anchorMsgId].push(re)):q.__orphans.push(re);return q}),J=k=>{let $=K(k);return $?(_.value||{})[$]||[]:[]},se=Vue.computed(()=>(_.value||{}).__orphans||[]),me=Vue.ref(!0),z=Vue.ref(!1),ee=_t.bottomThreshold,fe=_t.resumeBottomThreshold,ae=!0,De=Vue.computed(()=>s.messages.some(k=>k.isStreaming)),$e=Vue.computed(()=>!s.activeConversationId||W.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),Oe=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),je=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),Yt=Vue.computed(()=>!!s.sessionLoading&&!$e.value),kt=Vue.computed(()=>s.isProcessing&&!De.value),Dt=Vue.ref(Date.now()),St=null,Lt=()=>{St||(St=setInterval(()=>{Dt.value=Date.now()},1e3))},ft=()=>{St&&(clearInterval(St),St=null)};Vue.watch(De,k=>{k?(Dt.value=Date.now(),Lt()):ft()},{immediate:!0}),Vue.onBeforeUnmount(()=>ft());let Ne=Vue.ref(0),We=Vue.ref(Date.now()),$t=null,Ge=null,P=Vue.ref("cat"),X=new URLSearchParams(window.location.search).get("preview"),ge=Vue.ref(0),de=Vue.ref(1),ye=Vue.ref(5),Se=Vue.ref(95),Le=Vue.ref("bark-both"),He=Vue.ref(1),Be=Vue.ref(-1),Ke=null;function Vt(){if(!Ne.value)return;We.value=Date.now();let k=(We.value-Ne.value)%19e3;if(k<4e3)ge.value=0,de.value=1;else if(k<11500){let $=k-4e3,q;$<2500?q=$/2500*16:$<5e3?q=16+($-2500)/2500*29:q=45+($-5e3)/2500*55,ge.value=q,de.value=1}else k<14e3?(ge.value=(1-(k-11500)/2500)*100,de.value=-1):(ge.value=0,de.value=1);Ge=requestAnimationFrame(Vt)}function sn(){if(!Ne.value||P.value!=="dog")return;We.value=Date.now();let k=(We.value-Ne.value)%18e3;if(k<2e3)ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1;else if(k<5e3){let $=(k-2e3)/3e3;ye.value=5+$*25,Se.value=95,Le.value="left-approach",He.value=1,Be.value=-1}else if(k<8e3){let $=(k-5e3)/3e3;ye.value=30,Se.value=95-$*25,Le.value="right-approach",He.value=1,Be.value=-1}else if(k<1e4){let $=(k-8e3)/2e3;ye.value=30+$*13,Se.value=70-$*13,Le.value="both-approach",He.value=1,Be.value=-1}else if(k<11e3)ye.value=43,Se.value=57,Le.value="snap",He.value=1,Be.value=-1;else if(k<12500)ye.value=43,Se.value=57,Le.value="stunned",He.value=1,Be.value=-1;else if(k<15e3){let $=(k-12500)/2500;ye.value=43-$*38,Se.value=57+$*38,Le.value="retreat",He.value=-1,Be.value=1}else k<17e3?(ye.value=5,Se.value=95,Le.value="rehang",He.value=-1,Be.value=1):(ye.value=5,Se.value=95,Le.value="reset",He.value=1,Be.value=-1);Ke=requestAnimationFrame(sn)}let Ni=Vue.computed(()=>{let k=ye.value*1.2;return He.value<0?`translate(${k+13.5}, 0) scale(-1, 1)`:`translate(${k-13.5}, 0)`}),Bi=Vue.computed(()=>{let k=Se.value*1.2;return Be.value>0?`translate(${k-10.5}, 2)`:`translate(${k+10.5}, 2) scale(-1, 1)`}),er=Vue.computed(()=>{let k=Le.value;return k==="bark-both"||k==="left-approach"||k==="right-approach"||k==="both-approach"||k==="reset"}),tr=Vue.computed(()=>{let k=ye.value*1.2,$=10;if(er.value){let ke=Math.max(0,(k-3)*.12);return`M3,18 Q${(3+k)/2},${18+ke} ${k},${$}`}if(Le.value==="rehang")return`M${k},${$} Q${k-3},20 3,18`;let q=He.value<0?1:-1,pe=k+q*8;return`M${k},${$} Q${k},18 ${pe},22`}),Wi=Vue.computed(()=>{let k=Se.value*1.2,$=10;if(er.value){let ke=Math.max(0,(118-k)*.12);return`M118,18 Q${(118+k)/2},${18+ke} ${k},${$}`}if(Le.value==="rehang")return`M${k},${$} Q${k+3},20 118,18`;let q=Be.value>0?-1:1,pe=k+q*8;return`M${k},${$} Q${k},18 ${pe},22`}),Ui=Vue.computed(()=>Le.value==="snap"?.2:.4),ji=Vue.computed(()=>Le.value==="snap"?.2:.4),zi=Vue.computed(()=>ye.value*1.2),Ki=Vue.computed(()=>Se.value*1.2),nn=X==="cat"||X==="dog"||X==="animation",sr=600,rn=Vue.ref(!1),Je=null,nr=Vue.computed(()=>nn?!0:rn.value);Vue.watch(kt,k=>{if(k)Je&&(clearTimeout(Je),Je=null),rn.value=!0,Ne.value=Date.now(),We.value=Date.now(),P.value="cat",ge.value=0,de.value=1,ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1,P.value==="cat"?Ge=requestAnimationFrame(Vt):Ke=requestAnimationFrame(sn);else{let $=Ne.value?Date.now()-Ne.value:sr,q=Math.max(0,sr-$),pe=()=>{Je=null,rn.value=!1,Ne.value=0,ge.value=0,de.value=1,Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)};q===0?pe():(Je&&clearTimeout(Je),Je=setTimeout(pe,q))}},{immediate:!0}),nn&&(Ne.value=Date.now(),We.value=Date.now(),X==="dog"?P.value="dog":P.value="cat",P.value==="cat"?Ge=requestAnimationFrame(Vt):(ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1,Ke=requestAnimationFrame(sn)));let Yi=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let k=s.currentConversation;if(s.compactStatus?.conversationId===k&&s.compactStatus?.status==="compacting")return"compacting";let $=s.sessionHealth?.[k];return $?$.status:Ne.value&&We.value-Ne.value>8e3?"thinking":null}),Gi=Vue.computed(()=>{if(!Ne.value)return"speed-napping";let k=(We.value-Ne.value)%19e3;return k>=16e3?"speed-petted":k>=14e3?"speed-tired":k>=11500?"speed-crazy":k>=9e3?"speed-turbo":k>=6500?"speed-fast":k>=4e3?"speed-normal":"speed-napping"}),Qi=Vue.computed(()=>{let k=ge.value,$=de.value,pe={left:`calc(40px + (100% - 80px) * ${k/100})`};return $<0&&(pe.transform="scaleX(-1)"),pe});function et(){let k=s.currentConversation;if(!k)return;let $=s.conversations.find(q=>q.id===k);s.sendWsMessage({type:"refresh_conversation",conversationId:k,agentId:$?.agentId})}let rr=()=>{if(!o.value)return!0;let{scrollTop:k,scrollHeight:$,clientHeight:q}=o.value;return fs({scrollTop:k,scrollHeight:$,clientHeight:q,threshold:ee})},on=(k,$=0,{allowContinuation:q=!1}={})=>{if(k>up($)){ae=!0;return}q&&(ae=!0),!(!ae||!Xt())&&(ae=!1,or())},Xi=k=>{if(!k)return"";let q=(Array.isArray(k.items)?k.items:[])[0]||null;return[k.type||"",k.messageId||"",k.turnId||"",k.vpId||"",q?.id||"",q?.turnId||"",q?.messageId||""].join(":")},Gt=()=>{let k=W.value||[];return{blockCount:k.length,firstBlockIdentity:Xi(k[0])}},ir=(k,$)=>!k||!$?!1:$.blockCount>k.blockCount||$.firstBlockIdentity!==k.firstBlockIdentity,an=k=>{Vue.nextTick(()=>{if(!o.value)return;let $=Gt();ir(k,$)&&on(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},Zi=({scrollTop:k,scrollHeight:$,clientHeight:q})=>{let pe=fs({scrollTop:k,scrollHeight:$,clientHeight:q,threshold:ee});return me.value=pe,z.value=!pe,pe},Qt=()=>{z.value=!1,me.value=!0,a.value?.setBottomFollowEnabled?.(!0)},Ss=()=>{z.value=!0,me.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},Ji=({scrollTop:k,scrollHeight:$,clientHeight:q})=>{let pe=fs({scrollTop:k||0,scrollHeight:$||0,clientHeight:q||0,threshold:ee});me.value=pp({following:!z.value,atBottom:pe}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),It||(Ft=Number(k||0)),on(k||0,q||0)},eo=(k,$)=>{let q=Gt();if(!o.value){k(),an(q);return}let pe=o.value.scrollHeight,ke=o.value.scrollTop,re=!1,Ve=null,Ue=()=>{re||(re=!0,Ve&&Ve(),Vue.nextTick(()=>{if(!o.value)return;let we=o.value.scrollHeight;o.value.scrollTop=we-pe+ke,an(q)}))};$&&(Ve=Vue.watch($,we=>{we||Ue()})),k(),Vue.nextTick(()=>{(!$||!$())&&Ue()})},to=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},Xt=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,or=()=>{if(!Xt())return;let k=s.currentView==="yeaft";eo(k?to:()=>s.loadMoreMessages(),k?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},It=!1,Zt=!1,ot=null,Ft=0,so=250,ln=()=>{It=!1,ot&&(clearTimeout(ot),ot=null)},Is=()=>{Zt||(ot&&clearTimeout(ot),ot=setTimeout(ln,so))},Cs=k=>{It=!0,a.value?.clearTargetAnchor?.(),Ft=Number(o.value?.scrollTop||0),Number(k?.deltaY)<0&&Ss(),Is()},ar=k=>{gp(k,o.value)&&(Zt=!0,It=!0,a.value?.clearTargetAnchor?.(),Ft=Number(o.value?.scrollTop||0),ot&&(clearTimeout(ot),ot=null))},As=()=>{Zt=!1,Is()},lr=k=>{mp(k,o.value)&&((k.key==="ArrowUp"||k.key==="PageUp"||k.key==="Home")&&Ss(),It=!0,a.value?.clearTargetAnchor?.(),Is())},cr=()=>{let k=Number(o.value?.scrollTop||0),$=It?k-Ft:0,q=!z.value;Ft=k;let pe=rr(),ke=fs({scrollTop:k,scrollHeight:o.value?.scrollHeight||0,clientHeight:o.value?.clientHeight||0,threshold:fe});me.value=fp({following:q,atBottom:pe,resumeBoundaryReached:ke,direction:$}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),me.value&&cn(),It&&Is(),o.value&&on(o.value.scrollTop||0,o.value.clientHeight||0)},cn=()=>{s.currentView==="yeaft"&&s.pruneYeaftMessageWindow()},xs=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,Qt(),cn())},Jt=()=>{Qt(),Vue.nextTick(xs)},Ot=()=>{!z.value&&me.value&&(cn(),Vue.nextTick(xs))},dr=k=>{if(!k)return"";if(Array.isArray(k.items))return k.items.map(dr).join(",");let $=k.message||{};return[k.type||"",k.id||"",k.atMessageId||"",k.turnId||"",k.messageId||"",k.speakerVpId||"",$.id||"",$.content?String($.content).length:0,k.textContent?String(k.textContent).length:0,k.isStreaming||$.isStreaming?"streaming":"done"].join(":")},no=Vue.computed(()=>{let k=W.value||[];return[s.activeConversationId||"",U.value||"",dr(k[k.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,M.value.length,n.token],()=>{let k=n.token||"";k!==ne&&(ne=k,ve()),x()},{immediate:!0}),Vue.watch(no,Ot),Vue.watch(nr,k=>{k&&Ot()}),Vue.watch(()=>[s.activeConversationId,U.value],()=>{for(let k of Object.keys(l))delete l[k];for(let k of Object.keys(c))delete c[k];for(let k of Object.keys(d))delete d[k];Qt(),Vue.nextTick(xs)});let dn=Vue.ref(null),ur=0;return t({revealMessage:async k=>k?(Ss(),await xp({blocks:W.value,messageId:k,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(q,pe)=>(Ss(),a.value?.scrollToKey?.(q,pe)),findRow:q=>{let pe=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(pe).find(ke=>ke?.dataset?.msgId===q)||null},anchorRow:(q,pe,ke,re)=>a.value?.anchorTarget?.(q,ke,re),flashRow:q=>{let pe=++ur;dn.value=q,setTimeout(()=>{pe===ur&&(dn.value=null)},1800)}})):!1}),Vue.onMounted(()=>{xs(),o.value&&(o.value.addEventListener("wheel",Cs,{passive:!0}),o.value.addEventListener("touchmove",Cs,{passive:!0}),o.value.addEventListener("pointerdown",ar,{passive:!0}),o.value.addEventListener("scroll",cr)),window.addEventListener("pointerup",As,{passive:!0}),window.addEventListener("pointercancel",As,{passive:!0}),window.addEventListener("keydown",lr)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",Cs),o.value.removeEventListener("touchmove",Cs),o.value.removeEventListener("pointerdown",ar),o.value.removeEventListener("scroll",cr)),window.removeEventListener("pointerup",As),window.removeEventListener("pointercancel",As),window.removeEventListener("keydown",lr),ln(),$t&&(clearInterval($t),$t=null),Je&&(clearTimeout(Je),Je=null),Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:dn,hasStreamingMessage:De,nowMs:Dt,showTypingDots:kt,showInitialMessagesLoading:$e,showYeaftOlderHistoryLoading:Oe,showSessionLoadingOverlay:Yt,initialMessagesLoadingText:je,previewShowTypingDots:nr,isPreviewMode:nn,waitingStatus:Yi,animationType:P,catSpeed:Gi,catStyle:Qi,dogPhase:Le,spikeTransform:Ni,teddyTransform:Bi,leashPathL:tr,leashPathR:Wi,leashOpacityL:Ui,leashOpacityR:ji,questionLX:zi,questionRX:Ki,refreshSession:et,onlineAgents:M,welcomeInstallCommand:ue,welcomeLlmCommand:be,welcomeServiceCommand:ie,welcomeSetupLoading:R,welcomeSetupError:B,copyWelcomeCommand:Y,turnGroups:he,messageBlocks:W,virtualTranscriptIdentity:L,estimateMessageBlockHeight:b,visibleItemsForBlock:h,collapsedResponsePreviewLines:A,collapsedResponsePreviewSpeaker:w,responseToggleBelongsToItem:y,showBlockResponseToggle:m,toggleMessageTurnResponse:v,responseCollapseLabel:E,turnUiKey:u,assistantTurnActionsExpandedFor:f,setAssistantTurnActionsExpanded:p,toolExpandStates:c,setToolExpanded:g,cardsForRow:N,orphanCards:H,subAgentCardsForRow:J,orphanSubAgentCards:se,useImStyleForUser:D,onClickLoadMore:or,onVirtualTranscriptScrollState:Ji,isAtBottom:me,scrollToLatest:Jt}}}});function pi(...e){let t=[];for(let s of e)if(Array.isArray(s))for(let n of s)typeof n!="string"||!n||t.includes(n)||t.push(n);return t}function Rp(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?pi(n):pi(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function Wv(e,t={},s=new Set){if(Bv.has(e)||Object.prototype.hasOwnProperty.call(ui,e))return"builtin";let n=e.startsWith("/")?e.slice(1):e;return n.startsWith("skill:")||n.startsWith("yeaft-skills:")||s.has(n)&&Object.prototype.hasOwnProperty.call(t||{},n)?"skill":"project"}function _p(e,t={}){if(di[e])return di[e];if(ui[e])return ui[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Uv(s)}function Uv(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function Ep(e,t={},s=[]){if(e.length===0)return[];let n=new Set(s.filter(o=>typeof o=="string").map(o=>o.startsWith("/")?o.slice(1):o)),r={};e.forEach((o,a)=>{let l=Wv(o.cmd,o.descriptions||o.dynamicDescriptions||t,n);r[l]||(r[l]=[]),r[l].push({...o,flatIndex:a})});let i=Object.keys(r).sort((o,a)=>(Tp[o]??99)-(Tp[a]??99));return i.map((o,a)=>({label:jv[o]||o,items:r[o],isLast:a===i.length-1}))}var di,Bv,Mp,ui,Pp,jv,Tp,Dp=F(()=>{di={"/compact":"Compact context","/context":"Show context usage","/cost":"Show token costs","/init":"Reinitialize session","/doctor":"Check health status","/memory":"View/edit memory","/model":"View/switch model","/review":"Code review","/mcp":"MCP server status","/skills":"List available skills","/btw":"Side question (no history)","/insights":"Session insights","/pr-comments":"PR comment review","/release-notes":"Generate release notes","/security-review":"Security review"},Bv=new Set(Object.keys(di)),Mp=Object.keys(di),ui={"/low":"Use low reasoning effort for this turn","/medium":"Use medium reasoning effort for this turn","/high":"Use high reasoning effort for this turn","/xhigh":"Use extra-high reasoning effort for this turn","/max":"Use maximum reasoning effort for this turn"},Pp=Object.keys(ui);jv={skill:"Skills",builtin:"Built-in",project:"Commands"},Tp={skill:0,project:1,builtin:2}});function Gv(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Kv.test(e)||zv.has(e.toLowerCase()))}function fi(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;Lp.lastIndex=0;let s;for(;(s=Lp.exec(e))!==null;){let n=s[2];if(Gv(n)&&!t.has(n)&&(t.add(n),t.size>=Yv))break}return{text:e,mentions:Array.from(t)}}var zv,Lp,Kv,Yv,La=F(()=>{zv=new Set(["all","user","system","everyone"]),Lp=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Kv=/^[0-9]+$/,Yv=32});function $p(e){let t=typeof e?.vpId=="string"?e.vpId:"";return $a.has(t)?$a.get(t):e?.isStock===!0?"other":"custom"}function ms(e){let t=new Map(gi.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get($p(s)).push(s);return gi.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function zn(e){return ms(e).flatMap(t=>t.vps)}function Vp(e){let t=new Map(gi.map(r=>[r.id,r])),s=new Map,n=[];for(let r of Array.isArray(e)?e:[]){if(!r||typeof r.vpId!="string"||!r.vpId)continue;let i=$p(r),o=n[n.length-1];if(o&&o.id===i){o.vps.push(r);continue}let a=(s.get(i)||0)+1;s.set(i,a),n.push({id:i,key:`${i}-${a}`,labelKey:t.get(i).labelKey,vps:[r]})}return n}var Qv,gi,$a,Kn=F(()=>{Qv=[{id:"general",labelKey:"yeaft.vp.domain.general",vpIds:["omni"]},{id:"productDesign",labelKey:"yeaft.vp.domain.productDesign",vpIds:["steve","dieter","norman"]},{id:"softwareSystems",labelKey:"yeaft.vp.domain.softwareSystems",vpIds:["linus","martin","anders","ada","grace","ken","alan"]},{id:"securityReliability",labelKey:"yeaft.vp.domain.securityReliability",vpIds:["alice","margaret"]},{id:"scienceAnalysis",labelKey:"yeaft.vp.domain.scienceAnalysis",vpIds:["shannon","einstein"]},{id:"philosophyPsychology",labelKey:"yeaft.vp.domain.philosophyPsychology",vpIds:["kongzi","socrates","nietzsche","kahneman","jung"]},{id:"strategyHistory",labelKey:"yeaft.vp.domain.strategyHistory",vpIds:["sunzi","clausewitz","simaqian","harari"]},{id:"businessManagement",labelKey:"yeaft.vp.domain.businessManagement",vpIds:["buffett","munger","dalio","bezos","drucker"]},{id:"artsCulture",labelKey:"yeaft.vp.domain.artsCulture",vpIds:["luxun","sudongpo","borges","kubrick","miyazaki"]},{id:"other",labelKey:"yeaft.vp.domain.other",vpIds:[]},{id:"custom",labelKey:"yeaft.vp.domain.custom",vpIds:[]}],gi=Object.freeze(Qv.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),$a=new Map;for(let e of gi)for(let t of e.vpIds)$a.set(t,e.id)});function Va(e,t){let s=Array.isArray(e)?e:[],n=typeof t=="string"?t.toLowerCase():"";if(!n){let c=s.filter(d=>d&&d.vpId&&d.vpId!=="user");return zn(c).slice(0,Fp)}let r=[],i=[],o=[],a=new Set,l=(c,d)=>{a.has(c.vpId)||(a.add(c.vpId),d.push(c))};for(let c of s){if(!c||!c.vpId||c.vpId==="user")continue;if(String(c.vpId).toLowerCase().startsWith(n)){l(c,r);continue}let u=Array.isArray(c.aliases)?c.aliases:[],f=!1;for(let S of u){let y=String(S||"").toLowerCase();if(y&&y.startsWith(n)){f=!0;break}}if(f){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),g=String(c.displayNameZh||""),b=[c.description,c.descriptionZh,c.role,c.roleZh].map(S=>String(S||"").toLowerCase()),h=typeof t=="string"?t:"",A=p.includes(n)||h&&g.includes(h),w=n&&b.some(S=>S.includes(n));(A||w)&&l(c,o)}return[...zn(r),...zn(i),...zn(o)].slice(0,Fp)}function Fa(e="chat-input"){return`${e}-vp-mention-listbox`}function Oa(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function Xv(e){let t=0;return Vp(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function Op(e,t){let s=Array.isArray(e)?e:[];if(!t)return s;let n=Array.isArray(t.roster)?t.roster:[];if(n.length===0)return[];let r=new Set(n);return s.filter(i=>i&&i.vpId&&r.has(i.vpId))}function Hp(e,t){if(typeof e!="string"||!t)return e;let s=e.lastIndexOf("@");if(s<0)return e;let n=s+1;for(;n<e.length&&!/[\s]/.test(e[n]);)n++;return e.slice(0,s)+"@"+t+" "+e.slice(n)}var Fp,qp,Np=F(()=>{Kn();Fp=12;qp={name:"VpMentionAutocomplete",emits:["select","hover-index"],props:{vps:{type:Array,default:()=>[]},query:{type:String,default:""},selectedIndex:{type:Number,default:0},inputId:{type:String,required:!0}},template:`
|
|
1668
|
+
`,emits:["new-conversation","resume-conversation","open-settings","quote-message","edit-message-as-new"],setup(e,{expose:t}){let s=Pinia.useChatStore(),n=_e(),r=typeof window<"u"&&window.Pinia?.useVpStore?window.Pinia.useVpStore():null,i=Vue.inject("t",null),o=Vue.ref(null),a=Vue.ref(null),l=Vue.reactive({}),c=Vue.reactive({}),d=Vue.reactive({}),u=k=>String(k?.id||k?.turnId||k?.messageId||k?.atMessageId||k?.message?.id||"turn_unknown"),f=k=>{let $=u(k);return Object.prototype.hasOwnProperty.call(l,$)?!!l[$]:!1},p=(k,$)=>{l[u(k)]=!!$},g=({key:k,value:$}={})=>{k&&(c[k]=!!$)},b=k=>{let $=Sp(k,jt);return Number.isFinite($)?$:jt(k)},h=k=>li(k),A=k=>{let $=Array.isArray(k?.collapsedResponsePreview)?k.collapsedResponsePreview:kp(k);return Array.isArray($)?$:$?[String($)]:[]},w=k=>{let $=Array.isArray(k?.items)?k.items.find(we=>jn(we)):null,q=$?.speakerVpId||$?.vpId||$?.message?.speakerVpId||$?.message?.vpId||k?.vpId||"",pe=q&&r&&typeof r.vpLabel=="function"?r.vpLabel(q)||q:q||(typeof i=="function"?i("message.assistant"):"Assistant"),ke=q&&r&&typeof r.vpTextColor=="function"?{color:r.vpTextColor(q)}:{},re=$?.speakerTimestamp||$?.timestamp||$?.createdAt||$?.message?.timestamp||$?.message?.createdAt||0,Ve="",Ue="";if(re)try{let we=new Date(re);Number.isNaN(we.getTime())||(Ve=vt(re),Ue=we.toLocaleString())}catch{}return{name:pe,style:ke,timeText:Ve,fullTimeText:Ue}},S=k=>{let $=Array.isArray(k?.items)?k.items:[];for(let q=$.length-1;q>=0;q-=1)if(jn($[q]))return $[q];return null},y=(k,$)=>!k?.responseCollapsible||!$?!1:S(k)===$,m=k=>!!(k?.responseCollapsible&&!li(k).some($=>y(k,$))),v=k=>{let $=k?.responseCollapseKey;$&&(d[$]=!k.responseCollapsed)},E=k=>{let $=Number(k?.responseCount||0),q=k?.responseCollapsed?"message.showResponses":"message.hideResponses",pe=(typeof i=="function"?i(q):"")||(k?.responseCollapsed?"Show {count} response(s)":"Hide response(s)");return String(pe).replace("{count}",String($))},V=(()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}}),U=Vue.computed(()=>{if(s.currentView!=="yeaft")return null;let k=V();if(!k)return null;let $=s.yeaftActiveSessionFilter||null;return $&&typeof k.sessionById=="function"&&k.sessionById($,s.currentAgent||null)?$:k.activeSessionId&&typeof k.sessionById=="function"&&k.sessionById(k.activeSessionId,s.currentAgent||null)?k.activeSessionId:null}),L=Vue.computed(()=>{let k=s.currentView||"",$=s.currentAgent||"";if(k==="yeaft"){let q=s.yeaftActiveSessionFilter||U.value||"__all__";return[k,$,q].join("")}return[k,$,s.activeConversationId||""].join("")}),D=Vue.computed(()=>U.value!==null),M=Vue.computed(()=>s.agents.filter(k=>k.online)),T=Vue.ref(null),C=Vue.ref(null),R=Vue.ref(!1),B=Vue.ref(""),O=null,j=0,ne=n.token||"",ve=()=>{T.value=null,C.value=null,B.value="",O=null,j+=1},ue=Xr(),be=Zr(),ie=Vue.computed(()=>Jr({profile:T.value,agentSecret:C.value,serverWsUrl:On(location)})),Ce=()=>{let k={"Content-Type":"application/json"};return n.token&&(k.Authorization=`Bearer ${n.token}`),k},x=async()=>{if(M.value.length>0||s.currentConversation)return;if(C.value||O)return O;R.value=!0,B.value="";let k=++j;return O=(async()=>{let $=n.token||"",q=Ce(),[pe,ke]=await Promise.all([fetch("/api/user/profile",{headers:q}),fetch("/api/user/agent-secret",{headers:q})]),re=pe.ok?await pe.json():null;if(k!==j||$!==(n.token||""))return;if(re&&(T.value=re),!ke.ok){let we="";try{we=(await ke.json())?.error||""}catch{}throw new Error(we||"Failed to load Agent secret")}let Ve=await ke.json();if(k!==j||$!==(n.token||""))return;let Ue=Ve?.agentSecret||Ve?.agent_secret||null;C.value=Ue&&String(Ue).trim()?String(Ue):null})().catch($=>{k===j&&(B.value=$?.message||"Failed to load Agent secret")}).finally(()=>{k===j&&(R.value=!1,O=null)}),O},Y=async k=>{if(k)try{await navigator.clipboard.writeText(k)}catch{}},oe=(k,$)=>{let q=k?.message||null,pe=k?.id||k?.atMessageId||q?.id||q?.messageId||`legacy_${$}`,ke=k?.speakerVpId||k?.vpId||q?.speakerVpId||q?.vpId||"";return{id:`message_${ke||"user"}_${pe}_${$}`,vpId:ke,messageId:pe}},he=Vue.computed(()=>{let k=s.messages,$=[],q=null,pe=0,ke=()=>{if(q){q.isActive=!!(q.turnId&&Object.values(s.activeVpTurns||{}).some(Qe=>((Qe?.turnId||null)===q.turnId||!Qe?.turnId&&s.activeVpTurns?.[q.turnId]===Qe)&&(!s.currentAgent||!Qe?.agentId||Qe.agentId===s.currentAgent))),$r(q);let we=!!(q.textContent||q.todoMsg||q.askMsg||q.imageMsgs.length>0),ce=q.toolMsgs.length>0||q.toolSummaryCount>0;(we||ce)&&(q.showSpeakerHeader=!!q.speakerVpId,$.push(q)),q=null}},re=we=>{if(q){if(!q.speakerVpId){let ce=we.speakerVpId||we.vpId;ce&&(q.speakerVpId=ce,q.speakerTimestamp=typeof we.timestamp=="number"&&we.timestamp>0?we.timestamp:typeof we.createdAt=="number"?we.createdAt:0,typeof we.lastStateChangeCause=="string"&&!q.speakerStateCause&&(q.speakerStateCause=we.lastStateChangeCause))}!q.turnId&&we.turnId&&(q.turnId=we.turnId)}},Ve=()=>{pe++,q={type:"assistant-turn",id:"turn_"+pe,textContent:"",textSegments:[],isStreaming:!1,isActive:!1,isHistory:!1,todoMsg:null,toolMsgs:[],toolSummaryCount:0,imageMsgs:[],askMsg:null,messages:[],atMessageId:null,speakerVpId:null,speakerTimestamp:0,speakerStateCause:"",showSpeakerHeader:!1,turnId:null}},Ue=we=>{yp(q,we)&&ke()};for(let we=0;we<k.length;we++){let ce=k[we];if(ce.type==="user"){if(!ce.content||!ce.content.trim())continue;ke(),$.push({type:"user",id:ce.id||"u_"+we,message:ce});continue}if(ce.type==="system"||ce.type==="error"){ke(),$.push({type:ce.type,id:ce.id||"s_"+we,message:ce});continue}if(!(ce.type==="tool-result"||ce.type==="tool_result")){if(ce.type==="tool-summary"){Ue(ce),q||Ve(),re(ce),ce.isHistory&&(q.isHistory=!0),q.toolSummaryCount+=Number(ce.count||ce.omittedCount||0)||0,q.messages.push(ce);continue}if(ce.type==="assistant"){Ue(ce),q||Ve(),Lr(q,ce),ce.isStreaming&&(q.isStreaming=!0),ce.isHistory&&(q.isHistory=!0),ce.id&&/^m\d+$/.test(ce.id)&&(q.atMessageId=ce.id),re(ce),q.messages.push(ce);continue}if(ce.type==="tool-use"){Ue(ce),q||Ve(),re(ce);let Qe=k[we+1],Ts=Qe&&(Qe.type==="tool-result"||Qe.type==="tool_result"),un={...ce,hasResult:Ts||ce.hasResult||!1,toolResult:ce.toolResult||null};ce.isHistory&&(q.isHistory=!0),ce.toolName==="TodoWrite"?q.todoMsg=un:ce.toolName==="AskUserQuestion"?q.askMsg=un:q.toolMsgs.push(un),q.messages.push(ce);continue}if(ce.type==="chat-image"){Ue(ce),q||Ve(),re(ce),ce.isHistory&&(q.isHistory=!0),q.imageMsgs.push(ce),q.messages.push(ce);continue}ke(),$.push({type:ce.type||"unknown",id:ce.id||"x_"+we,message:ce})}}return ke(),$}),W=Vue.computed(()=>{let k=[],$=null,q=()=>{$&&k.push($),$=null};return he.value.forEach((pe,ke)=>{if(!pe||pe.type==="system"||pe.type==="error"){q(),k.push(pe);return}let re=oe(pe,ke);if(pe.type==="user"||!$){q(),$={type:"message-block",id:`turn_${re.messageId}_${ke}`,vpId:re.vpId,messageId:re.messageId,items:[pe]};return}$.items.push(pe),!$.vpId&&re.vpId&&($.vpId=re.vpId)}),q(),k}),te=Vue.computed(()=>{let k=s.yeaftReflectionCards||{},$=s.yeaftConversationId,q={__orphans:[]},pe=Object.values(k).filter(re=>re&&re.conversationId===$).sort((re,Ve)=>(re.anchorOrder||0)-(Ve.anchorOrder||0)||(re.updatedAt||0)-(Ve.updatedAt||0)),ke=new Set;for(let re of s.messages||[])re&&re.id&&ke.add(re.id);for(let re of pe)re.anchorMsgId&&ke.has(re.anchorMsgId)?(q[re.anchorMsgId]||(q[re.anchorMsgId]=[]),q[re.anchorMsgId].push(re)):q.__orphans.push(re);return q}),K=k=>k?k.type==="assistant-turn"?k.atMessageId||null:k.message&&k.message.id||null:null,N=k=>{let $=K(k);return $?(te.value||{})[$]||[]:[]},H=Vue.computed(()=>(te.value||{}).__orphans||[]),_=Vue.computed(()=>{let k=s.yeaftSubAgentCards||{},$=s.yeaftConversationId,q={__orphans:[]},pe=Object.values(k).filter(re=>re&&re.conversationId===$).sort((re,Ve)=>(re.anchorOrder||0)-(Ve.anchorOrder||0)||(re.updatedAt||0)-(Ve.updatedAt||0)),ke=new Set;for(let re of s.messages||[])re&&re.id&&ke.add(re.id);for(let re of pe)re.anchorMsgId&&ke.has(re.anchorMsgId)?(q[re.anchorMsgId]||(q[re.anchorMsgId]=[]),q[re.anchorMsgId].push(re)):q.__orphans.push(re);return q}),J=k=>{let $=K(k);return $?(_.value||{})[$]||[]:[]},se=Vue.computed(()=>(_.value||{}).__orphans||[]),me=Vue.ref(!0),z=Vue.ref(!1),ee=_t.bottomThreshold,fe=_t.resumeBottomThreshold,ae=!0,De=Vue.computed(()=>s.messages.some(k=>k.isStreaming)),$e=Vue.computed(()=>!s.activeConversationId||W.value.length>0?!1:s.currentView==="yeaft"?!!s.yeaftInitialHistoryLoading:!!s.sessionLoading),Oe=Vue.computed(()=>s.currentView==="yeaft"&&!!s.yeaftLoadingMoreHistory&&s.activeYeaftHistoryState?.mode==="older"),je=Vue.computed(()=>s.currentView==="yeaft"?"":s.sessionLoadingText||""),Gt=Vue.computed(()=>!!s.sessionLoading&&!$e.value),kt=Vue.computed(()=>s.isProcessing&&!De.value),Dt=Vue.ref(Date.now()),St=null,Lt=()=>{St||(St=setInterval(()=>{Dt.value=Date.now()},1e3))},ft=()=>{St&&(clearInterval(St),St=null)};Vue.watch(De,k=>{k?(Dt.value=Date.now(),Lt()):ft()},{immediate:!0}),Vue.onBeforeUnmount(()=>ft());let Ne=Vue.ref(0),We=Vue.ref(Date.now()),$t=null,Ge=null,P=Vue.ref("cat"),X=new URLSearchParams(window.location.search).get("preview"),ge=Vue.ref(0),de=Vue.ref(1),ye=Vue.ref(5),Se=Vue.ref(95),Le=Vue.ref("bark-both"),He=Vue.ref(1),Be=Vue.ref(-1),Ke=null;function Vt(){if(!Ne.value)return;We.value=Date.now();let k=(We.value-Ne.value)%19e3;if(k<4e3)ge.value=0,de.value=1;else if(k<11500){let $=k-4e3,q;$<2500?q=$/2500*16:$<5e3?q=16+($-2500)/2500*29:q=45+($-5e3)/2500*55,ge.value=q,de.value=1}else k<14e3?(ge.value=(1-(k-11500)/2500)*100,de.value=-1):(ge.value=0,de.value=1);Ge=requestAnimationFrame(Vt)}function sn(){if(!Ne.value||P.value!=="dog")return;We.value=Date.now();let k=(We.value-Ne.value)%18e3;if(k<2e3)ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1;else if(k<5e3){let $=(k-2e3)/3e3;ye.value=5+$*25,Se.value=95,Le.value="left-approach",He.value=1,Be.value=-1}else if(k<8e3){let $=(k-5e3)/3e3;ye.value=30,Se.value=95-$*25,Le.value="right-approach",He.value=1,Be.value=-1}else if(k<1e4){let $=(k-8e3)/2e3;ye.value=30+$*13,Se.value=70-$*13,Le.value="both-approach",He.value=1,Be.value=-1}else if(k<11e3)ye.value=43,Se.value=57,Le.value="snap",He.value=1,Be.value=-1;else if(k<12500)ye.value=43,Se.value=57,Le.value="stunned",He.value=1,Be.value=-1;else if(k<15e3){let $=(k-12500)/2500;ye.value=43-$*38,Se.value=57+$*38,Le.value="retreat",He.value=-1,Be.value=1}else k<17e3?(ye.value=5,Se.value=95,Le.value="rehang",He.value=-1,Be.value=1):(ye.value=5,Se.value=95,Le.value="reset",He.value=1,Be.value=-1);Ke=requestAnimationFrame(sn)}let Ni=Vue.computed(()=>{let k=ye.value*1.2;return He.value<0?`translate(${k+13.5}, 0) scale(-1, 1)`:`translate(${k-13.5}, 0)`}),Bi=Vue.computed(()=>{let k=Se.value*1.2;return Be.value>0?`translate(${k-10.5}, 2)`:`translate(${k+10.5}, 2) scale(-1, 1)`}),er=Vue.computed(()=>{let k=Le.value;return k==="bark-both"||k==="left-approach"||k==="right-approach"||k==="both-approach"||k==="reset"}),tr=Vue.computed(()=>{let k=ye.value*1.2,$=10;if(er.value){let ke=Math.max(0,(k-3)*.12);return`M3,18 Q${(3+k)/2},${18+ke} ${k},${$}`}if(Le.value==="rehang")return`M${k},${$} Q${k-3},20 3,18`;let q=He.value<0?1:-1,pe=k+q*8;return`M${k},${$} Q${k},18 ${pe},22`}),Wi=Vue.computed(()=>{let k=Se.value*1.2,$=10;if(er.value){let ke=Math.max(0,(118-k)*.12);return`M118,18 Q${(118+k)/2},${18+ke} ${k},${$}`}if(Le.value==="rehang")return`M${k},${$} Q${k+3},20 118,18`;let q=Be.value>0?-1:1,pe=k+q*8;return`M${k},${$} Q${k},18 ${pe},22`}),Ui=Vue.computed(()=>Le.value==="snap"?.2:.4),ji=Vue.computed(()=>Le.value==="snap"?.2:.4),zi=Vue.computed(()=>ye.value*1.2),Ki=Vue.computed(()=>Se.value*1.2),nn=X==="cat"||X==="dog"||X==="animation",sr=600,rn=Vue.ref(!1),Je=null,nr=Vue.computed(()=>nn?!0:rn.value);Vue.watch(kt,k=>{if(k)Je&&(clearTimeout(Je),Je=null),rn.value=!0,Ne.value=Date.now(),We.value=Date.now(),P.value="cat",ge.value=0,de.value=1,ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1,P.value==="cat"?Ge=requestAnimationFrame(Vt):Ke=requestAnimationFrame(sn);else{let $=Ne.value?Date.now()-Ne.value:sr,q=Math.max(0,sr-$),pe=()=>{Je=null,rn.value=!1,Ne.value=0,ge.value=0,de.value=1,Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)};q===0?pe():(Je&&clearTimeout(Je),Je=setTimeout(pe,q))}},{immediate:!0}),nn&&(Ne.value=Date.now(),We.value=Date.now(),X==="dog"?P.value="dog":P.value="cat",P.value==="cat"?Ge=requestAnimationFrame(Vt):(ye.value=5,Se.value=95,Le.value="bark-both",He.value=1,Be.value=-1,Ke=requestAnimationFrame(sn)));let Yi=Vue.computed(()=>{if(!s.isProcessing)return null;if(s.connectionState!=="connected")return"disconnected";let k=s.currentConversation;if(s.compactStatus?.conversationId===k&&s.compactStatus?.status==="compacting")return"compacting";let $=s.sessionHealth?.[k];return $?$.status:Ne.value&&We.value-Ne.value>8e3?"thinking":null}),Gi=Vue.computed(()=>{if(!Ne.value)return"speed-napping";let k=(We.value-Ne.value)%19e3;return k>=16e3?"speed-petted":k>=14e3?"speed-tired":k>=11500?"speed-crazy":k>=9e3?"speed-turbo":k>=6500?"speed-fast":k>=4e3?"speed-normal":"speed-napping"}),Qi=Vue.computed(()=>{let k=ge.value,$=de.value,pe={left:`calc(40px + (100% - 80px) * ${k/100})`};return $<0&&(pe.transform="scaleX(-1)"),pe});function et(){let k=s.currentConversation;if(!k)return;let $=s.conversations.find(q=>q.id===k);s.sendWsMessage({type:"refresh_conversation",conversationId:k,agentId:$?.agentId})}let rr=()=>{if(!o.value)return!0;let{scrollTop:k,scrollHeight:$,clientHeight:q}=o.value;return gs({scrollTop:k,scrollHeight:$,clientHeight:q,threshold:ee})},on=(k,$=0,{allowContinuation:q=!1}={})=>{if(k>up($)){ae=!0;return}q&&(ae=!0),!(!ae||!Zt())&&(ae=!1,or())},Xi=k=>{if(!k)return"";let q=(Array.isArray(k.items)?k.items:[])[0]||null;return[k.type||"",k.messageId||"",k.turnId||"",k.vpId||"",q?.id||"",q?.turnId||"",q?.messageId||""].join(":")},Qt=()=>{let k=W.value||[];return{blockCount:k.length,firstBlockIdentity:Xi(k[0])}},ir=(k,$)=>!k||!$?!1:$.blockCount>k.blockCount||$.firstBlockIdentity!==k.firstBlockIdentity,an=k=>{Vue.nextTick(()=>{if(!o.value)return;let $=Qt();ir(k,$)&&on(o.value.scrollTop||0,o.value.clientHeight||0,{allowContinuation:!0})})},Zi=({scrollTop:k,scrollHeight:$,clientHeight:q})=>{let pe=gs({scrollTop:k,scrollHeight:$,clientHeight:q,threshold:ee});return me.value=pe,z.value=!pe,pe},Xt=()=>{z.value=!1,me.value=!0,a.value?.setBottomFollowEnabled?.(!0)},Ss=()=>{z.value=!0,me.value=!1,a.value?.setBottomFollowEnabled?.(!1),a.value?.cancelPendingBottomFollow?.()},Ji=({scrollTop:k,scrollHeight:$,clientHeight:q})=>{let pe=gs({scrollTop:k||0,scrollHeight:$||0,clientHeight:q||0,threshold:ee});me.value=pp({following:!z.value,atBottom:pe}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),It||(Ft=Number(k||0)),on(k||0,q||0)},eo=(k,$)=>{let q=Qt();if(!o.value){k(),an(q);return}let pe=o.value.scrollHeight,ke=o.value.scrollTop,re=!1,Ve=null,Ue=()=>{re||(re=!0,Ve&&Ve(),Vue.nextTick(()=>{if(!o.value)return;let we=o.value.scrollHeight;o.value.scrollTop=we-pe+ke,an(q)}))};$&&(Ve=Vue.watch($,we=>{we||Ue()})),k(),Vue.nextTick(()=>{(!$||!$())&&Ue()})},to=()=>{if(s.hasHiddenYeaftMessages){s.expandYeaftMessageWindow();return}s.loadMoreYeaftHistory()},Zt=()=>s.currentView==="yeaft"?s.hasHiddenYeaftMessages||s.yeaftHasMoreHistory&&!s.yeaftLoadingMoreHistory&&s.yeaftOldestLoadedSeq!=null:!!s.currentConversation&&s.hasMoreMessages&&!s.loadingMoreMessages,or=()=>{if(!Zt())return;let k=s.currentView==="yeaft";eo(k?to:()=>s.loadMoreMessages(),k?()=>s.yeaftLoadingMoreHistory:()=>s.loadingMoreMessages)},It=!1,Jt=!1,ot=null,Ft=0,so=250,ln=()=>{It=!1,ot&&(clearTimeout(ot),ot=null)},Is=()=>{Jt||(ot&&clearTimeout(ot),ot=setTimeout(ln,so))},Cs=k=>{It=!0,a.value?.clearTargetAnchor?.(),Ft=Number(o.value?.scrollTop||0),Number(k?.deltaY)<0&&Ss(),Is()},ar=k=>{gp(k,o.value)&&(Jt=!0,It=!0,a.value?.clearTargetAnchor?.(),Ft=Number(o.value?.scrollTop||0),ot&&(clearTimeout(ot),ot=null))},As=()=>{Jt=!1,Is()},lr=k=>{mp(k,o.value)&&((k.key==="ArrowUp"||k.key==="PageUp"||k.key==="Home")&&Ss(),It=!0,a.value?.clearTargetAnchor?.(),Is())},cr=()=>{let k=Number(o.value?.scrollTop||0),$=It?k-Ft:0,q=!z.value;Ft=k;let pe=rr(),ke=gs({scrollTop:k,scrollHeight:o.value?.scrollHeight||0,clientHeight:o.value?.clientHeight||0,threshold:fe});me.value=fp({following:q,atBottom:pe,resumeBoundaryReached:ke,direction:$}),z.value=!me.value,a.value?.setBottomFollowEnabled?.(me.value),me.value&&cn(),It&&Is(),o.value&&on(o.value.scrollTop||0,o.value.clientHeight||0)},cn=()=>{s.currentView==="yeaft"&&s.pruneYeaftMessageWindow()},xs=()=>{o.value&&(o.value.scrollTop=o.value.scrollHeight,Xt(),cn())},es=()=>{Xt(),Vue.nextTick(xs)},Ot=()=>{!z.value&&me.value&&(cn(),Vue.nextTick(xs))},dr=k=>{if(!k)return"";if(Array.isArray(k.items))return k.items.map(dr).join(",");let $=k.message||{};return[k.type||"",k.id||"",k.atMessageId||"",k.turnId||"",k.messageId||"",k.speakerVpId||"",$.id||"",$.content?String($.content).length:0,k.textContent?String(k.textContent).length:0,k.isStreaming||$.isStreaming?"streaming":"done"].join(":")},no=Vue.computed(()=>{let k=W.value||[];return[s.activeConversationId||"",U.value||"",dr(k[k.length-1])].join("|")});Vue.watch(()=>[s.currentConversation,M.value.length,n.token],()=>{let k=n.token||"";k!==ne&&(ne=k,ve()),x()},{immediate:!0}),Vue.watch(no,Ot),Vue.watch(nr,k=>{k&&Ot()}),Vue.watch(()=>[s.activeConversationId,U.value],()=>{for(let k of Object.keys(l))delete l[k];for(let k of Object.keys(c))delete c[k];for(let k of Object.keys(d))delete d[k];Xt(),Vue.nextTick(xs)});let dn=Vue.ref(null),ur=0;return t({revealMessage:async k=>k?(Ss(),await xp({blocks:W.value,messageId:k,collapseStates:d,nextTick:Vue.nextTick,scrollToBlock:(q,pe)=>(Ss(),a.value?.scrollToKey?.(q,pe)),findRow:q=>{let pe=o.value?.querySelectorAll?.("[data-msg-id]")||[];return Array.from(pe).find(ke=>ke?.dataset?.msgId===q)||null},anchorRow:(q,pe,ke,re)=>a.value?.anchorTarget?.(q,ke,re),flashRow:q=>{let pe=++ur;dn.value=q,setTimeout(()=>{pe===ur&&(dn.value=null)},1800)}})):!1}),Vue.onMounted(()=>{xs(),o.value&&(o.value.addEventListener("wheel",Cs,{passive:!0}),o.value.addEventListener("touchmove",Cs,{passive:!0}),o.value.addEventListener("pointerdown",ar,{passive:!0}),o.value.addEventListener("scroll",cr)),window.addEventListener("pointerup",As,{passive:!0}),window.addEventListener("pointercancel",As,{passive:!0}),window.addEventListener("keydown",lr)}),Vue.onUnmounted(()=>{o.value&&(o.value.removeEventListener("wheel",Cs),o.value.removeEventListener("touchmove",Cs),o.value.removeEventListener("pointerdown",ar),o.value.removeEventListener("scroll",cr)),window.removeEventListener("pointerup",As),window.removeEventListener("pointercancel",As),window.removeEventListener("keydown",lr),ln(),$t&&(clearInterval($t),$t=null),Je&&(clearTimeout(Je),Je=null),Ge&&(cancelAnimationFrame(Ge),Ge=null),Ke&&(cancelAnimationFrame(Ke),Ke=null)}),{store:s,containerRef:o,virtualTranscriptRef:a,flashMsgId:dn,hasStreamingMessage:De,nowMs:Dt,showTypingDots:kt,showInitialMessagesLoading:$e,showYeaftOlderHistoryLoading:Oe,showSessionLoadingOverlay:Gt,initialMessagesLoadingText:je,previewShowTypingDots:nr,isPreviewMode:nn,waitingStatus:Yi,animationType:P,catSpeed:Gi,catStyle:Qi,dogPhase:Le,spikeTransform:Ni,teddyTransform:Bi,leashPathL:tr,leashPathR:Wi,leashOpacityL:Ui,leashOpacityR:ji,questionLX:zi,questionRX:Ki,refreshSession:et,onlineAgents:M,welcomeInstallCommand:ue,welcomeLlmCommand:be,welcomeServiceCommand:ie,welcomeSetupLoading:R,welcomeSetupError:B,copyWelcomeCommand:Y,turnGroups:he,messageBlocks:W,virtualTranscriptIdentity:L,estimateMessageBlockHeight:b,visibleItemsForBlock:h,collapsedResponsePreviewLines:A,collapsedResponsePreviewSpeaker:w,responseToggleBelongsToItem:y,showBlockResponseToggle:m,toggleMessageTurnResponse:v,responseCollapseLabel:E,turnUiKey:u,assistantTurnActionsExpandedFor:f,setAssistantTurnActionsExpanded:p,toolExpandStates:c,setToolExpanded:g,cardsForRow:N,orphanCards:H,subAgentCardsForRow:J,orphanSubAgentCards:se,useImStyleForUser:D,onClickLoadMore:or,onVirtualTranscriptScrollState:Ji,isAtBottom:me,scrollToLatest:es}}}});function pi(...e){let t=[];for(let s of e)if(Array.isArray(s))for(let n of s)typeof n!="string"||!n||t.includes(n)||t.push(n);return t}function Rp(e,t,s){let n=t?e?.slashCommandsMap?.[t]:null;return e?.currentView==="yeaft"?pi(n):pi(n,s?e?.slashCommandsMap?.[`agent:${s}`]:null,e?.slashCommandsMap?.__preload__)}function Wv(e,t={},s=new Set){if(Bv.has(e)||Object.prototype.hasOwnProperty.call(ui,e))return"builtin";let n=e.startsWith("/")?e.slice(1):e;return n.startsWith("skill:")||n.startsWith("yeaft-skills:")||s.has(n)&&Object.prototype.hasOwnProperty.call(t||{},n)?"skill":"project"}function _p(e,t={}){if(di[e])return di[e];if(ui[e])return ui[e];let s=e.startsWith("/")?e.slice(1):e;return t[s]?t[s]:Uv(s)}function Uv(e){return(e.includes(":")?e.split(":").pop():e).replace(/-/g," ").replace(/^\w/,s=>s.toUpperCase())}function Ep(e,t={},s=[]){if(e.length===0)return[];let n=new Set(s.filter(o=>typeof o=="string").map(o=>o.startsWith("/")?o.slice(1):o)),r={};e.forEach((o,a)=>{let l=Wv(o.cmd,o.descriptions||o.dynamicDescriptions||t,n);r[l]||(r[l]=[]),r[l].push({...o,flatIndex:a})});let i=Object.keys(r).sort((o,a)=>(Tp[o]??99)-(Tp[a]??99));return i.map((o,a)=>({label:jv[o]||o,items:r[o],isLast:a===i.length-1}))}var di,Bv,Mp,ui,Pp,jv,Tp,Dp=F(()=>{di={"/compact":"Compact context","/context":"Show context usage","/cost":"Show token costs","/init":"Reinitialize session","/doctor":"Check health status","/memory":"View/edit memory","/model":"View/switch model","/review":"Code review","/mcp":"MCP server status","/skills":"List available skills","/btw":"Side question (no history)","/insights":"Session insights","/pr-comments":"PR comment review","/release-notes":"Generate release notes","/security-review":"Security review"},Bv=new Set(Object.keys(di)),Mp=Object.keys(di),ui={"/low":"Use low reasoning effort for this turn","/medium":"Use medium reasoning effort for this turn","/high":"Use high reasoning effort for this turn","/xhigh":"Use extra-high reasoning effort for this turn","/max":"Use maximum reasoning effort for this turn"},Pp=Object.keys(ui);jv={skill:"Skills",builtin:"Built-in",project:"Commands"},Tp={skill:0,project:1,builtin:2}});function Gv(e){return!(!e||typeof e!="string"||e.length<1||e.length>40||e.startsWith("_")||Kv.test(e)||zv.has(e.toLowerCase()))}function fi(e){if(!e||typeof e!="string")return{text:e||"",mentions:[]};let t=new Set;Lp.lastIndex=0;let s;for(;(s=Lp.exec(e))!==null;){let n=s[2];if(Gv(n)&&!t.has(n)&&(t.add(n),t.size>=Yv))break}return{text:e,mentions:Array.from(t)}}var zv,Lp,Kv,Yv,La=F(()=>{zv=new Set(["all","user","system","everyone"]),Lp=/(^|[\s\p{P}])@([A-Za-z0-9_-]{1,40})(?=$|[\s\p{P}])/gu,Kv=/^[0-9]+$/,Yv=32});function $p(e){let t=typeof e?.vpId=="string"?e.vpId:"";return $a.has(t)?$a.get(t):e?.isStock===!0?"other":"custom"}function hs(e){let t=new Map(gi.map(s=>[s.id,[]]));for(let s of Array.isArray(e)?e:[])!s||typeof s.vpId!="string"||!s.vpId||t.get($p(s)).push(s);return gi.map(s=>({id:s.id,labelKey:s.labelKey,vps:t.get(s.id)})).filter(s=>s.vps.length>0)}function zn(e){return hs(e).flatMap(t=>t.vps)}function Vp(e){let t=new Map(gi.map(r=>[r.id,r])),s=new Map,n=[];for(let r of Array.isArray(e)?e:[]){if(!r||typeof r.vpId!="string"||!r.vpId)continue;let i=$p(r),o=n[n.length-1];if(o&&o.id===i){o.vps.push(r);continue}let a=(s.get(i)||0)+1;s.set(i,a),n.push({id:i,key:`${i}-${a}`,labelKey:t.get(i).labelKey,vps:[r]})}return n}var Qv,gi,$a,Kn=F(()=>{Qv=[{id:"general",labelKey:"yeaft.vp.domain.general",vpIds:["omni"]},{id:"productDesign",labelKey:"yeaft.vp.domain.productDesign",vpIds:["steve","dieter","norman"]},{id:"softwareSystems",labelKey:"yeaft.vp.domain.softwareSystems",vpIds:["linus","martin","anders","ada","grace","ken","alan"]},{id:"securityReliability",labelKey:"yeaft.vp.domain.securityReliability",vpIds:["alice","margaret"]},{id:"scienceAnalysis",labelKey:"yeaft.vp.domain.scienceAnalysis",vpIds:["shannon","einstein"]},{id:"philosophyPsychology",labelKey:"yeaft.vp.domain.philosophyPsychology",vpIds:["kongzi","socrates","nietzsche","kahneman","jung"]},{id:"strategyHistory",labelKey:"yeaft.vp.domain.strategyHistory",vpIds:["sunzi","clausewitz","simaqian","harari"]},{id:"businessManagement",labelKey:"yeaft.vp.domain.businessManagement",vpIds:["buffett","munger","dalio","bezos","drucker"]},{id:"artsCulture",labelKey:"yeaft.vp.domain.artsCulture",vpIds:["luxun","sudongpo","borges","kubrick","miyazaki"]},{id:"other",labelKey:"yeaft.vp.domain.other",vpIds:[]},{id:"custom",labelKey:"yeaft.vp.domain.custom",vpIds:[]}],gi=Object.freeze(Qv.map(e=>Object.freeze({id:e.id,labelKey:e.labelKey,vpIds:Object.freeze([...e.vpIds])}))),$a=new Map;for(let e of gi)for(let t of e.vpIds)$a.set(t,e.id)});function Va(e,t){let s=Array.isArray(e)?e:[],n=typeof t=="string"?t.toLowerCase():"";if(!n){let c=s.filter(d=>d&&d.vpId&&d.vpId!=="user");return zn(c).slice(0,Fp)}let r=[],i=[],o=[],a=new Set,l=(c,d)=>{a.has(c.vpId)||(a.add(c.vpId),d.push(c))};for(let c of s){if(!c||!c.vpId||c.vpId==="user")continue;if(String(c.vpId).toLowerCase().startsWith(n)){l(c,r);continue}let u=Array.isArray(c.aliases)?c.aliases:[],f=!1;for(let S of u){let y=String(S||"").toLowerCase();if(y&&y.startsWith(n)){f=!0;break}}if(f){l(c,i);continue}let p=String(c.displayName||"").toLowerCase(),g=String(c.displayNameZh||""),b=[c.description,c.descriptionZh,c.role,c.roleZh].map(S=>String(S||"").toLowerCase()),h=typeof t=="string"?t:"",A=p.includes(n)||h&&g.includes(h),w=n&&b.some(S=>S.includes(n));(A||w)&&l(c,o)}return[...zn(r),...zn(i),...zn(o)].slice(0,Fp)}function Fa(e="chat-input"){return`${e}-vp-mention-listbox`}function Oa(e,t){let s=String(t||"").replace(/[^A-Za-z0-9_.:-]/g,"-");return`${e}-vp-mention-option-${s}`}function Xv(e){let t=0;return Vp(e).map(s=>({...s,items:s.vps.map(n=>({vp:n,flatIndex:t++}))}))}function Op(e,t){let s=Array.isArray(e)?e:[];if(!t)return s;let n=Array.isArray(t.roster)?t.roster:[];if(n.length===0)return[];let r=new Set(n);return s.filter(i=>i&&i.vpId&&r.has(i.vpId))}function Hp(e,t){if(typeof e!="string"||!t)return e;let s=e.lastIndexOf("@");if(s<0)return e;let n=s+1;for(;n<e.length&&!/[\s]/.test(e[n]);)n++;return e.slice(0,s)+"@"+t+" "+e.slice(n)}var Fp,qp,Np=F(()=>{Kn();Fp=12;qp={name:"VpMentionAutocomplete",emits:["select","hover-index"],props:{vps:{type:Array,default:()=>[]},query:{type:String,default:""},selectedIndex:{type:Number,default:0},inputId:{type:String,required:!0}},template:`
|
|
1669
1669
|
<div
|
|
1670
1670
|
class="slash-autocomplete vp-mention-autocomplete"
|
|
1671
1671
|
v-if="filteredList.length > 0"
|
|
@@ -1874,8 +1874,8 @@ ${String(e||"").trim()}
|
|
|
1874
1874
|
</button>
|
|
1875
1875
|
</div>
|
|
1876
1876
|
</footer>
|
|
1877
|
-
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Pinia.useVpStore(),i=Pinia.useSessionsStore?Pinia.useSessionsStore():null,o=Vue.ref(""),a=Vue.ref(null),c=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>u.value.some(P=>P.uploading)),p=Vue.ref(null),g=Vue.ref(null),b=Vue.ref(null),h=Vue.computed(()=>!!e.sendFn),A=Vue.computed(()=>!s.btwMode),w=Vue.computed(()=>e.placeholderKey||"chatInput.placeholder"),S=Vue.computed(()=>e.showStop||!h.value&&s.isProcessing),y=Vue.computed({get:()=>s.expertSelections||[],set:P=>{s.expertSelections=P}}),m=Vue.ref(!1),v=Vue.ref(0),E=Vue.computed(()=>Qc(s.customExpertRoles)),V=Vue.computed(()=>{let P=o.value,X=P.lastIndexOf("@");if(X===-1||!m.value)return[];let ge=P.slice(X+1).toLowerCase();return E.value.filter(de=>ge?de.searchText.includes(ge):!0).filter(de=>!y.value.some(ye=>ye.role===de.roleId)).slice(0,12)}),U=P=>{if(y.value.length>=
|
|
1878
|
-
`||ge===0?R()?(T.value=!0,C.value=0,m.value=!1):(m.value=!0,v.value=0,T.value=!1):(m.value=!1,T.value=!1)}else ge===-1&&(m.value=!1,T.value=!1)},ee=P=>{o.value=P+" ",x.value=!1,Vue.nextTick(()=>{a.value?.focus()})},fe=()=>{setTimeout(()=>{x.value=!1,m.value=!1,T.value=!1},150)},ae=async P=>{let X=Array.from(P.target.files||[]);X.length>0&&await Dt(X),P.target.value="",Vue.nextTick(()=>{a.value?.focus()})},De=async P=>{let X=P.clipboardData?.items;if(!X)return;let ge=[];for(let de of X)if(de.kind==="file"){let ye=de.getAsFile();ye&&ge.push(ye)}ge.length>0&&(P.preventDefault(),await Dt(ge))},$e=P=>{let X=String(P||"").toLowerCase();return X==="image/png"?".png":X==="image/jpeg"?".jpg":X==="image/gif"?".gif":X==="image/webp"?".webp":X==="image/svg+xml"?".svg":X==="text/plain"?".txt":X==="application/json"?".json":""},Oe=(P,X)=>{let ge=typeof P?.name=="string"?P.name.trim():"";return ge||`${String(P?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${X+1}${$e(P?.type)}`},je=1,
|
|
1877
|
+
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Pinia.useVpStore(),i=Pinia.useSessionsStore?Pinia.useSessionsStore():null,o=Vue.ref(""),a=Vue.ref(null),c=`chat-input-${Vue.getCurrentInstance()?.uid??0}`,d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>u.value.some(P=>P.uploading)),p=Vue.ref(null),g=Vue.ref(null),b=Vue.ref(null),h=Vue.computed(()=>!!e.sendFn),A=Vue.computed(()=>!s.btwMode),w=Vue.computed(()=>e.placeholderKey||"chatInput.placeholder"),S=Vue.computed(()=>e.showStop||!h.value&&s.isProcessing),y=Vue.computed({get:()=>s.expertSelections||[],set:P=>{s.expertSelections=P}}),m=Vue.ref(!1),v=Vue.ref(0),E=Vue.computed(()=>Qc(s.customExpertRoles)),V=Vue.computed(()=>{let P=o.value,X=P.lastIndexOf("@");if(X===-1||!m.value)return[];let ge=P.slice(X+1).toLowerCase();return E.value.filter(de=>ge?de.searchText.includes(ge):!0).filter(de=>!y.value.some(ye=>ye.role===de.roleId)).slice(0,12)}),U=P=>{if(y.value.length>=as)return;let X={role:P.roleId,action:P.actionId};s.expertSelections=[...y.value,X];let ge=o.value,de=ge.lastIndexOf("@");de!==-1&&(o.value=ge.slice(0,de).trimEnd()),m.value=!1,Vue.nextTick(()=>a.value?.focus())},L=P=>{let X=[...y.value];X.splice(P,1),s.expertSelections=X},D=P=>os(P,s.customExpertRoles),M=P=>P==="completed"?"\u2713":P==="in_progress"?"\u2192":"\u25CB",T=Vue.ref(!1),C=Vue.ref(0),R=()=>s.currentView==="yeaft"&&!!s.currentAgent,B=Vue.computed(()=>{let P=o.value,X=P.lastIndexOf("@");return X<0||!T.value?"":P.slice(X+1)}),O=Vue.computed(()=>{if(!i)return r.vpList||[];let P=s.yeaftActiveSessionFilter||i.activeSessionId||null,X=typeof i.sessionById=="function"?i.sessionById(P,s.currentAgent||null):i.sessions?.[P];return Op(r.vpList,X)}),j=Vue.computed(()=>Va(O.value,B.value)),ne=Vue.computed(()=>!s.btwMode&&T.value&&!m.value&&j.value.length>0),ve=Fa(c),ue=Vue.computed(()=>{if(!ne.value)return null;let P=j.value[C.value];return P?Oa(c,P.vpId):null}),be=P=>{!P||!P.vpId||(o.value=Hp(o.value,P.vpId),T.value=!1,C.value=0,Vue.nextTick(()=>a.value?.focus()))},ie=Vue.computed(()=>e.draftKey||e.conversationId||s.currentConversation||null);ie.value&&s.inputDrafts[ie.value]&&(o.value=s.inputDrafts[ie.value]),Vue.watch(o,P=>{let X=ie.value;X&&(P?s.inputDrafts[X]=P:delete s.inputDrafts[X])}),Vue.watch(j,P=>{if(P.length===0){C.value=0;return}C.value>=P.length&&(C.value=P.length-1)}),Vue.watch(ie,(P,X)=>{X&&o.value&&(s.inputDrafts[X]=o.value),o.value=P&&s.inputDrafts[P]||""});let Ce=P=>{if(!P||typeof P!="string")return;let X=o.value||"",ge=X.length>0&&!/\s$/.test(X),de=X+(ge?" ":"")+"@"+P+" ";o.value=de,Vue.nextTick(()=>{let ye=a.value;ye&&(ye.focus(),ye.setSelectionRange(de.length,de.length),se())})},x=Vue.ref(!1),Y=Vue.ref(0),oe=Vue.computed(()=>{let P=e.conversationId||s.activeConversationId||s.currentConversation,X=s.currentAgent,ge=Rp(s,P,X),de=s.currentView==="yeaft"?Pp:Mp;return pi(de,ge).map(Se=>Se.startsWith("/")?Se:"/"+Se)}),he=Vue.computed(()=>{let P=o.value.trim();if(!P.startsWith("/"))return[];let X=P.toLowerCase();return oe.value.filter(ge=>ge.toLowerCase().startsWith(X)&&ge.toLowerCase()!==X).map(ge=>({cmd:ge,desc:_p(ge,s.slashCommandDescriptions)}))}),W=Vue.computed(()=>Ep(he.value,s.slashCommandDescriptions,oe.value)),te=Vue.computed(()=>he.value.map(P=>P.cmd)),K=Vue.computed(()=>e.conversationId||s.activeConversationId||s.currentConversation||null),N=Vue.computed(()=>s.compactStatus?.status==="compacting"&&s.compactStatus?.conversationId===K.value),H=P=>typeof P?.fileId=="string"&&P.fileId.trim().length>0,_=Vue.computed(()=>{if(N.value)return!1;let P=!!o.value.trim(),X=u.value.length>0;if(h.value){let Le=!f.value&&u.value.every(H);return(P||X)&&Le}let ge=y.value.length>0,de=y.value.some(Le=>Le.action),ye=P||X||ge&&(P||de),Se=!f.value&&u.value.every(H);return ye&&s.currentAgent&&s.currentConversation&&Se}),J=120,se=()=>{let P=a.value;if(!P)return;P.style.height="auto";let X=Math.min(P.scrollHeight,J);P.style.height=X+"px",P.style.overflowY=P.scrollHeight>J?"auto":"hidden"},me=()=>{let P=a.value;P&&(P.style.height="auto",P.style.overflowY="hidden")},z=()=>{se();let P=o.value.trim();P.startsWith("/")&&!P.includes(" ")?(x.value=!0,Y.value=0,m.value=!1):x.value=!1;let X=o.value,ge=X.lastIndexOf("@");if(ge!==-1&&!x.value){let de=ge>0?X[ge-1]:" ";de===" "||de===`
|
|
1878
|
+
`||ge===0?R()?(T.value=!0,C.value=0,m.value=!1):(m.value=!0,v.value=0,T.value=!1):(m.value=!1,T.value=!1)}else ge===-1&&(m.value=!1,T.value=!1)},ee=P=>{o.value=P+" ",x.value=!1,Vue.nextTick(()=>{a.value?.focus()})},fe=()=>{setTimeout(()=>{x.value=!1,m.value=!1,T.value=!1},150)},ae=async P=>{let X=Array.from(P.target.files||[]);X.length>0&&await Dt(X),P.target.value="",Vue.nextTick(()=>{a.value?.focus()})},De=async P=>{let X=P.clipboardData?.items;if(!X)return;let ge=[];for(let de of X)if(de.kind==="file"){let ye=de.getAsFile();ye&&ge.push(ye)}ge.length>0&&(P.preventDefault(),await Dt(ge))},$e=P=>{let X=String(P||"").toLowerCase();return X==="image/png"?".png":X==="image/jpeg"?".jpg":X==="image/gif"?".gif":X==="image/webp"?".webp":X==="image/svg+xml"?".svg":X==="text/plain"?".txt":X==="application/json"?".json":""},Oe=(P,X)=>{let ge=typeof P?.name=="string"?P.name.trim():"";return ge||`${String(P?.type||"").startsWith("image/")?"pasted-image":"pasted-file"}-${Date.now()}-${X+1}${$e(P?.type)}`},je=1,Gt=P=>{let X=Number(P);return!Number.isFinite(X)||X<=0?"":X<1024?`${X} B`:X<1024*1024?`${Math.round(X/1024)} KB`:`${(X/(1024*1024)).toFixed(X<10*1024*1024?1:0)} MB`},kt=async P=>{for(let X of P)X.uploading=!0,X.uploadError=!1;try{let X=new FormData;for(let He of P)X.append("files",He.file,He.uploadName);let ge={},de=n.getActiveToken?.()||n.token||null;de&&(ge.Authorization=`Bearer ${de}`);let ye=await fetch("/api/upload",{method:"POST",headers:ge,body:X});if(!ye.ok)throw new Error("Upload failed");let Se=await ye.json(),Le=Array.isArray(Se.files)?Se.files:[];for(let[He,Be]of P.entries()){let Ke=Le[He],Vt=typeof Ke?.fileId=="string"?Ke.fileId.trim():"";if(!Vt)throw new Error("Upload response is incomplete");Be.fileId=Vt,Be.uploading=!1,delete Be.uploadName}}catch{for(let ge of P)ge.fileId||(ge.uploading=!1,ge.uploadError=!0)}finally{Vue.nextTick(()=>a.value?.focus())}},Dt=async P=>{let X=[];for(let[ge,de]of P.entries()){let ye=Oe(de,ge),Se=Vue.reactive({localId:`attachment-${je++}`,file:de,name:ye,size:de.size,uploadName:ye,preview:null,uploading:!1,uploadError:!1,fileId:null});de.type.startsWith("image/")&&(Se.preview=URL.createObjectURL(de)),u.value.push(Se),X.push(Se)}await kt(X)},St=async P=>{!P||P.uploading||P.fileId||(P.uploadName=P.name,await kt([P]))},Lt=P=>{let X=u.value[P];X.preview&&URL.revokeObjectURL(X.preview),u.value.splice(P,1),Vue.nextTick(()=>{a.value?.focus()})},ft=()=>{if(!_.value)return;x.value=!1,m.value=!1,T.value=!1;let P=o.value.trim();if(e.sendFn){let de=u.value.filter(H).map(Se=>({fileId:Se.fileId,name:Se.name,preview:Se.preview,isImage:Se.file?.type?.startsWith("image/")||!1,mimeType:Se.file?.type||""})),ye=de.length>0?de:void 0;e.quote?e.sendFn(P,ye,e.quote):e.sendFn(P,ye),u.value=[],e.quote&&t("quote-consumed"),o.value="",ie.value&&delete s.inputDrafts[ie.value],me();return}if(P==="/btw"||P.startsWith("/btw ")){let de=P.substring(4).trim();s.enterBtwMode(),de&&s.sendBtwQuestion(de),o.value="",ie.value&&delete s.inputDrafts[ie.value],me();return}if(s.btwMode){s.sendBtwQuestion(P),o.value="",ie.value&&delete s.inputDrafts[ie.value],me();return}let X=u.value.filter(H).map(de=>({fileId:de.fileId,name:de.name,preview:de.preview,isImage:de.file?.type?.startsWith("image/")||!1,mimeType:de.file?.type||""}));if(s.currentView==="yeaft"&&(P||X.length>0)){let de=fi(P).mentions,ye=s.yeaftActiveSessionFilter||i?.activeSessionId||"grp_default";s.sendYeaftSessionMessage({groupId:ye,text:P,mentions:de,attachments:X}),u.value=[],o.value="",ie.value&&delete s.inputDrafts[ie.value],me();return}let ge=[...y.value];s.sendMessage(o.value.trim(),X,{expertSelections:ge}),u.value=[],o.value="",s.expertSelections=[],ie.value&&delete s.inputDrafts[ie.value],me()},Ne=P=>{if(!(P.isComposing||P.keyCode===229)){if(P.key==="Escape"&&s.btwMode){P.preventDefault(),s.closeBtw();return}if(T.value){let X=j.value;if(X.length>0){if(P.key==="ArrowDown"){P.preventDefault(),C.value=(C.value+1)%X.length;return}if(P.key==="ArrowUp"){P.preventDefault(),C.value=(C.value-1+X.length)%X.length;return}if(P.key==="Tab"||P.key==="Enter"&&!P.shiftKey){P.preventDefault(),be(X[C.value]);return}}if(P.key==="Escape"){P.preventDefault(),T.value=!1;return}}if(m.value&&V.value.length>0){if(P.key==="ArrowDown"){P.preventDefault(),v.value=(v.value+1)%V.value.length;return}if(P.key==="ArrowUp"){P.preventDefault(),v.value=(v.value-1+V.value.length)%V.value.length;return}if(P.key==="Tab"||P.key==="Enter"&&!P.shiftKey){P.preventDefault(),U(V.value[v.value]);return}if(P.key==="Escape"){P.preventDefault(),m.value=!1;return}}if(x.value&&te.value.length>0){if(P.key==="ArrowDown"){P.preventDefault(),Y.value=(Y.value+1)%te.value.length;return}if(P.key==="ArrowUp"){P.preventDefault(),Y.value=(Y.value-1+te.value.length)%te.value.length;return}if(P.key==="Tab"||P.key==="Enter"&&!P.shiftKey){P.preventDefault(),ee(te.value[Y.value]);return}if(P.key==="Escape"){P.preventDefault(),x.value=!1;return}}P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),ft())}},We=()=>{e.cancelFn?e.cancelFn():s.cancelExecution()},$t=P=>{o.value=typeof P=="string"?P:"",Vue.nextTick(()=>{se(),a.value?.focus();let X=o.value.length;a.value?.setSelectionRange(X,X)})},Ge=()=>Vue.nextTick(()=>a.value?.focus());return{store:s,inputText:o,inputRef:a,inputAreaRef:p,fileInput:d,attachments:u,uploading:f,canSend:_,isCompacting:N,isStopVisible:S,effectivePlaceholderKey:w,attachmentsAllowed:A,showAutocomplete:x,selectedIndex:Y,filteredCommands:te,flatItems:he,groupedCommands:W,autocompleteRef:g,sendFn:Vue.toRef(e,"sendFn"),expertSelections:y,showExpertAutocomplete:m,expertSelectedIndex:v,expertAutocompleteFiltered:V,expertAutocompleteRef:b,selectExpertItem:U,removeExpertSelection:L,getExpertLabel:D,todoStatusSymbol:M,autoResize:se,handleInput:z,selectCommand:ee,onBlur:fe,handleFileSelect:ae,handlePaste:De,formatFileSize:Gt,retryAttachment:St,removeAttachment:Lt,send:ft,handleKeydown:Ne,cancelExecution:We,vpStore:r,inputElementId:c,showVpAutocomplete:T,vpMentionPopupOpen:ne,vpMentionPopupId:ve,vpMentionActiveOptionId:ue,vpSelectedIndex:C,vpMentionQuery:B,mentionVpCandidates:O,selectVpMention:be,appendMention:Ce,replaceDraft:$t,focusInput:Ge}}}});function Ha(e){return new Promise((t,s)=>{if(document.querySelector(`script[src="${e}"]`))return t();let n=document.createElement("script");n.src=e,n.onload=t,n.onerror=s,document.head.appendChild(n)})}function Bp(e){return e+":"+Math.random().toString(36).slice(2,8)}function Yn(e){return e?e.type==="pane"?[e.terminalId]:[...Yn(e.first),...Yn(e.second)]:[]}function vi(e){return e?e.type==="pane"?e.terminalId:vi(e.first):null}function hi(e,t,s){return e&&(e.type==="pane"?e.terminalId===t?s:e:{...e,first:hi(e.first,t,s),second:hi(e.second,t,s)})}function zt(e,t){if(!e)return null;if(e.type==="pane")return e.terminalId===t?null:e;if(e.first?.type==="pane"&&e.first.terminalId===t)return e.second;if(e.second?.type==="pane"&&e.second.terminalId===t)return e.first;let s=zt(e.first,t),n=zt(e.second,t);return s?n?{...e,first:s,second:n}:s:n}var Wp=F(()=>{});var Up,jp=F(()=>{Up={name:"PaneTree",props:{node:Object,terminals:Object,activePane:String,onActivate:Function,onClosePane:Function,setMountRef:Function},template:`
|
|
1879
1879
|
<div v-if="node.type === 'pane'"
|
|
1880
1880
|
class="terminal-pane"
|
|
1881
1881
|
:class="{ active: node.terminalId === activePane }"
|
|
@@ -1948,7 +1948,7 @@ ${String(e||"").trim()}
|
|
|
1948
1948
|
<div class="placeholder-text">{{ $t('terminal.autoCreate') }}</div>
|
|
1949
1949
|
</div>
|
|
1950
1950
|
</div>
|
|
1951
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.ref(""),o={},a=!1,l=Vue.computed(()=>{let T=e.currentConversation;return T&&n[T]||null}),c=Vue.computed(()=>{let T=e.currentConversation;return T&&r[T]||""}),d=Vue.computed(()=>!!c.value),u=(T,C)=>{if(C){let R=o[T];if(o[T]=C,R&&R!==C){let B=s[T];B?.terminal?.element&&(C.innerHTML="",C.appendChild(B.terminal.element),Vue.nextTick(()=>{try{B.fitAddon?.fit()}catch{}}))}}},f=T=>{let C=e.currentConversation;C&&(r[C]=T)};async function p(){if(a)return!0;let T=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!T||!C)try{await Ha("vendor/xterm.min.js"),await Ha("vendor/xterm-addon-fit.min.js"),T=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!T||!C?(i.value=t("terminal.xtermNotLoaded"),!1):(a=!0,!0)}function g(){let T=document.documentElement.getAttribute("data-theme")==="dark",R=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(T?"#212121":"#ffffff");return T?{background:R,foreground:"#d4d4d4",cursor:"#a0a0a0",selectionBackground:"rgba(255,255,255,0.12)",black:"#3a3a3a",red:"#f48771",green:"#89d185",yellow:"#e5c07b",blue:"#6cb6ff",magenta:"#d670d6",cyan:"#56d4dd",white:"#cccccc",brightBlack:"#555555",brightRed:"#f48771",brightGreen:"#89d185",brightYellow:"#e5c07b",brightBlue:"#6cb6ff",brightMagenta:"#d670d6",brightCyan:"#56d4dd",brightWhite:"#e8e8e8"}:{background:R,foreground:"#383a42",cursor:"#526fff",selectionBackground:"rgba(0,0,0,0.07)",black:"#383a42",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a1a7",brightBlack:"#4f525e",brightRed:"#e45649",brightGreen:"#50a14f",brightYellow:"#c18401",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#fafafa"}}async function b(T){if(!T||!e.currentAgent||!await p())return null;let C=Bp(T),R=Terminal.Terminal||Terminal,B=FitAddon.FitAddon||FitAddon,O=new R({cursorBlink:!0,fontSize:13,fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace, 'Symbols Nerd Font Mono', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji'",theme:g(),allowProposedApi:!0}),j=new B;return O.loadAddon(j),O.attachCustomKeyEventHandler(ne=>!((ne.ctrlKey||ne.metaKey)&&ne.key==="v"||(ne.ctrlKey||ne.metaKey)&&ne.key==="c"&&O.hasSelection())),s[C]={created:!0,connected:!1,terminal:O,fitAddon:j},O.onData(ne=>{e.sendWsMessage({type:"terminal_input",agentId:e.currentAgent,conversationId:T,terminalId:C,data:ne,_clientId:e.clientId})}),C}async function h(T,C){let R=s[C];if(!R)return!1;let B=null;for(let O=0;O<10&&(await Vue.nextTick(),B=o[C],!(B||O>=2&&(await new Promise(j=>setTimeout(j,50)),B=o[C],B)));O++);return B?(R.terminal.open(B),R.fitAddon.fit(),e.sendWsMessage({type:"terminal_create",agentId:e.currentAgent,conversationId:T,terminalId:C,cols:R.terminal.cols,rows:R.terminal.rows,_clientId:e.clientId}),!0):(i.value=t("terminal.mountFailed"),R.terminal.dispose(),delete s[C],!1)}let A=!1;async function w(){let T=e.currentConversation;if(!T||!e.currentAgent||n[T]||A)return;A=!0,i.value="";let C=await b(T);if(!C){A=!1;return}n[T]=Vue.reactive({type:"pane",terminalId:C}),r[T]=C,await h(T,C)||(delete n[T],delete r[T]),A=!1}async function S(T){let C=e.currentConversation;if(!C||!r[C])return;let R=r[C],B=await b(C);if(!B)return;let O=Vue.reactive({type:"split",direction:T,ratio:.5,first:{type:"pane",terminalId:R},second:{type:"pane",terminalId:B}}),j=hi(n[C],R,O);if(n[C]=Vue.reactive(j),r[C]=B,!await h(C,B)){let ve=zt(n[C],B);ve&&(n[C]=Vue.reactive(ve)),r[C]=R;return}await Vue.nextTick(),v(C)}function y(T){let C=e.currentConversation;if(!C)return;let R=s[T];R&&(e.sendWsMessage({type:"terminal_close",agentId:e.currentAgent,conversationId:C,terminalId:T,_clientId:e.clientId}),R.terminal?.dispose(),delete s[T],delete o[T]);let B=zt(n[C],T);B?(n[C]=Vue.reactive(B),r[C]===T&&(r[C]=vi(n[C])||""),Vue.nextTick(()=>v(C))):(delete n[C],delete r[C],Vue.nextTick(()=>w()))}function m(){let T=e.currentConversation;!T||!r[T]||y(r[T])}function v(T){if(T||(T=e.currentConversation),!T||!n[T])return;let C=Yn(n[T]);for(let R of C){let B=s[R];if(B?.fitAddon&&B.connected)try{B.fitAddon.fit(),e.sendWsMessage({type:"terminal_resize",agentId:e.currentAgent,conversationId:T,terminalId:R,cols:B.terminal.cols,rows:B.terminal.rows,_clientId:e.clientId})}catch{}}}function E(T){let C=T.detail;if(C)switch(C.type){case"terminal_created":{let R=C.terminalId||C.conversationId,B=s[R];if(B)if(C.success)B.connected=!0,i.value="";else{i.value=C.error||t("terminal.createFailed"),B.terminal?.dispose(),delete s[R];let O=C.conversationId;if(O&&n[O]){let j=zt(n[O],R);j?n[O]=Vue.reactive(j):(delete n[O],delete r[O])}}break}case"terminal_output":{let R=C.terminalId||C.conversationId,B=s[R];B?.terminal&&B.terminal.write(C.data);break}case"terminal_closed":{let R=C.terminalId||C.conversationId,B=s[R];if(B){B.terminal?.dispose(),delete s[R],delete o[R];let O=C.conversationId;if(O&&n[O]){let j=zt(n[O],R);j?(n[O]=Vue.reactive(j),r[O]===R&&(r[O]=vi(n[O])||"")):(delete n[O],delete r[O])}}break}case"terminal_error":{i.value=C.message||t("terminal.error");let R=C.terminalId;if(R&&s[R]&&!s[R].connected){s[R].terminal?.dispose(),delete s[R];let B=C.conversationId;if(B&&n[B]){let O=zt(n[B],R);O?n[B]=Vue.reactive(O):(delete n[B],delete r[B])}}break}}}let V=null;function U(){clearTimeout(V),V=setTimeout(()=>v(),100)}function L(){v()}function D(T){let{conversationId:C}=T.detail;if(C&&n[C]){let R=Yn(n[C]);for(let B of R){let O=s[B];O&&(O.terminal?.dispose(),delete s[B],delete o[B])}delete n[C],delete r[C]}}Vue.onMounted(()=>{window.addEventListener("workbench-message",E),window.addEventListener("resize",U),window.addEventListener("terminal-fit-all",L),window.addEventListener("conversation-deleted",D)}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",E),window.removeEventListener("resize",U),window.removeEventListener("terminal-fit-all",L),window.removeEventListener("conversation-deleted",D),clearTimeout(V);for(let T of Object.keys(s))s[T]?.terminal?.dispose()}),Vue.watch(()=>[e.currentConversation,e.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!e.currentConversation||!e.workbenchExpanded)return;let C=document.querySelector(".terminal-tab");C&&C.offsetParent!==null&&w()})},{immediate:!0}),Vue.watch(()=>e.connectionState,(T,C)=>{if(T==="connected"&&C&&C!=="connected"){for(let R of Object.keys(s))s[R]?.terminal?.dispose(),delete s[R],delete o[R];for(let R of Object.keys(n))delete n[R],delete r[R];Vue.nextTick(()=>w())}}),Vue.watch(()=>e.currentConversation,()=>{Vue.nextTick(()=>v())});let M=null;return Vue.onMounted(()=>{let T=()=>{let R=document.querySelector(".terminal-tab");R&&R.offsetParent!==null&&(w(),v())};M=new MutationObserver(()=>{setTimeout(T,50)});let C=document.querySelector(".workbench-tab-content");C&&M.observe(C,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{M&&M.disconnect()}),{store:e,terminals:s,currentTree:l,currentActivePane:c,hasActivePane:d,terminalError:i,setMountRef:u,activatePane:f,splitPane:S,closeActivePane:m,closePane:y}}}});function yi(e){if(!e)return Gn(Z.default);let t=e.toLowerCase();if(qa[t])return qa[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(Yp[n])return Yp[n]();let r=t;for(let[i,o]of Object.entries(qa))if(r===i||r.endsWith("/"+i))return o()}return Gn(Z.default)}function bi(e=!1){return Zv(Z.folder,e)}var Z,Gn,Zv,Q,Yp,qa,Na=F(()=>{Z={js:"#F1C40F",ts:"#3178C6",jsx:"#61DAFB",tsx:"#3178C6",py:"#3776AB",rb:"#CC342D",go:"#00ADD8",rs:"#DEA584",java:"#E76F00",cs:"#68217A",cpp:"#00599C",c:"#A8B9CC",html:"#E44D26",css:"#1572B6",scss:"#CF649A",less:"#1D365D",json:"#F1C40F",yaml:"#CB171E",xml:"#E44D26",md:"#519ABA",txt:"#8E8E8E",log:"#8E8E8E",sh:"#4EAA25",ps1:"#012456",sql:"#E38C00",svg:"#FFB13B",img:"#26A69A",git:"#F05032",docker:"#2496ED",config:"#6D8086",lock:"#8E8E8E",env:"#ECD53F",vue:"#41B883",react:"#61DAFB",angular:"#DD0031",svelte:"#FF3E00",php:"#777BB4",swift:"#FA7343",kt:"#7F52FF",lua:"#000080",r:"#276DC3",dart:"#00B4AB",liquid:"#67B6E4",folder:"#90A4AE",folderOpen:"#90A4AE",default:"#8E8E8E"},Gn=e=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.85"/><path d="M14 2v6h6" fill="${e}" opacity="0.5"/></svg>`,Zv=(e,t)=>t?`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z" fill="${e}" opacity="0.9"/></svg>`:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" fill="${e}" opacity="0.9"/></svg>`,Q=(e,t)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.2"/><path d="M14 2v6h6" fill="${e}" opacity="0.15"/><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" stroke="${e}" stroke-width="1.2" fill="none"/><text x="12" y="17" text-anchor="middle" font-size="7" font-weight="700" font-family="system-ui,sans-serif" fill="${e}">${t}</text></svg>`,Yp={js:()=>Q(Z.js,"JS"),mjs:()=>Q(Z.js,"JS"),cjs:()=>Q(Z.js,"JS"),ts:()=>Q(Z.ts,"TS"),mts:()=>Q(Z.ts,"TS"),jsx:()=>Q(Z.jsx,"JSX"),tsx:()=>Q(Z.tsx,"TSX"),html:()=>Q(Z.html,"</>"),htm:()=>Q(Z.html,"</>"),css:()=>Q(Z.css,"CSS"),scss:()=>Q(Z.scss,"SC"),sass:()=>Q(Z.scss,"SA"),less:()=>Q(Z.less,"LS"),vue:()=>Q(Z.vue,"V"),svelte:()=>Q(Z.svelte,"SV"),json:()=>Q(Z.json,"{ }"),yaml:()=>Q(Z.yaml,"YML"),yml:()=>Q(Z.yaml,"YML"),toml:()=>Q(Z.config,"TML"),xml:()=>Q(Z.xml,"</>"),csv:()=>Q(Z.config,"CSV"),md:()=>Q(Z.md,"MD"),markdown:()=>Q(Z.md,"MD"),txt:()=>Gn(Z.txt),log:()=>Gn(Z.log),pdf:()=>Q("#E53935","PDF"),py:()=>Q(Z.py,"PY"),rb:()=>Q(Z.rb,"RB"),go:()=>Q(Z.go,"GO"),rs:()=>Q(Z.rs,"RS"),java:()=>Q(Z.java,"JA"),cs:()=>Q(Z.cs,"C#"),cpp:()=>Q(Z.cpp,"C+"),cc:()=>Q(Z.cpp,"C+"),c:()=>Q(Z.c,"C"),h:()=>Q(Z.c,"H"),hpp:()=>Q(Z.cpp,"H+"),swift:()=>Q(Z.swift,"SW"),kt:()=>Q(Z.kt,"KT"),php:()=>Q(Z.php,"PHP"),lua:()=>Q(Z.lua,"LUA"),r:()=>Q(Z.r,"R"),dart:()=>Q(Z.dart,"DA"),sh:()=>Q(Z.sh,">_"),bash:()=>Q(Z.sh,">_"),zsh:()=>Q(Z.sh,">_"),fish:()=>Q(Z.sh,">_"),ps1:()=>Q(Z.ps1,"PS"),bat:()=>Q(Z.ps1,"BAT"),cmd:()=>Q(Z.ps1,"CMD"),sql:()=>Q(Z.sql,"SQL"),db:()=>Q(Z.sql,"DB"),sqlite:()=>Q(Z.sql,"DB"),svg:()=>Q(Z.svg,"SVG"),png:()=>Q(Z.img,"PNG"),jpg:()=>Q(Z.img,"JPG"),jpeg:()=>Q(Z.img,"JPG"),gif:()=>Q(Z.img,"GIF"),ico:()=>Q(Z.img,"ICO"),webp:()=>Q(Z.img,"WP"),lock:()=>Gn(Z.lock),env:()=>Q(Z.env,"ENV"),ini:()=>Q(Z.config,"INI"),cfg:()=>Q(Z.config,"CFG"),conf:()=>Q(Z.config,"CNF"),liquid:()=>Q(Z.liquid,"LQ"),ejs:()=>Q(Z.html,"EJS"),hbs:()=>Q(Z.html,"HBS"),pug:()=>Q(Z.html,"PUG"),wasm:()=>Q("#654FF0","WA"),proto:()=>Q(Z.config,"PB"),graphql:()=>Q("#E535AB","GQL"),gql:()=>Q("#E535AB","GQL")},qa={dockerfile:()=>Q(Z.docker,"DK"),"docker-compose.yml":()=>Q(Z.docker,"DC"),"docker-compose.yaml":()=>Q(Z.docker,"DC"),".gitignore":()=>Q(Z.git,"GI"),".gitattributes":()=>Q(Z.git,"GA"),".gitmodules":()=>Q(Z.git,"GM"),".env":()=>Q(Z.env,"ENV"),".env.local":()=>Q(Z.env,"ENV"),".env.development":()=>Q(Z.env,"ENV"),".env.production":()=>Q(Z.env,"ENV"),"package.json":()=>Q("#CB3837","NPM"),"package-lock.json":()=>Q("#CB3837","NPM"),"tsconfig.json":()=>Q(Z.ts,"TSC"),eslintrc:()=>Q("#4B32C3","ESL"),".eslintrc.js":()=>Q("#4B32C3","ESL"),".eslintrc.json":()=>Q("#4B32C3","ESL"),".prettierrc":()=>Q("#F7B93E","PR"),makefile:()=>Q(Z.config,"MK"),"cmakelists.txt":()=>Q("#064F8C","CM"),"readme.md":()=>Q(Z.md,"RM"),license:()=>Q("#F5C518","LIC"),"license.md":()=>Q("#F5C518","LIC"),"cargo.toml":()=>Q(Z.rs,"CG"),"go.mod":()=>Q(Z.go,"MOD"),"go.sum":()=>Q(Z.go,"SUM"),gemfile:()=>Q(Z.rb,"GEM"),rakefile:()=>Q(Z.rb,"RK"),"requirements.txt":()=>Q(Z.py,"REQ"),pipfile:()=>Q(Z.py,"PIP"),csproj:()=>Q(Z.cs,"CSP"),".sln":()=>Q(Z.cs,"SLN"),slnx:()=>Q(Z.cs,"SLN")}});function hs(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Jv(e,t){if(!e||!t)return hs(e);let s=[],n=(a,l)=>{if(!a)return;let c=new RegExp(a.source,a.flags),d;for(;(d=c.exec(e))!==null;){let u=d[1]!==void 0?d[1]:d[0],f=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:f,end:f+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(Qs.comment1,xe.comment),n(Qs.commentBlock,xe.comment)),(r==="hash"||r==="both")&&n(Qs.commentHash,xe.comment),r==="html"&&n(t.commentHtml,xe.comment),t.commentLine&&n(t.commentLine,xe.comment),t.commentBlock&&n(t.commentBlock,xe.comment),n(Qs.string,xe.string),n(Qs.number,xe.number),t.keywords&&n(t.keywords,xe.keyword),t.builtins&&n(t.builtins,xe.builtin),t.operators&&n(t.operators,xe.operator),t.decorators&&n(t.decorators,xe.decorator),t.macros&&n(t.macros,xe.macro),t.preprocessor&&n(t.preprocessor,xe.preprocessor),t.attributes&&n(t.attributes,xe.attribute),t.tags&&n(t.tags,xe.tag),t.properties&&n(t.properties,xe.property),t.variables&&n(t.variables,xe.variable),t.headings&&n(t.headings,xe.heading),t.bold&&n(t.bold,xe.bold),t.links&&n(t.links,xe.link),t.keys&&n(t.keys,xe.key),t.sections&&n(t.sections,xe.section),t.selectors&&n(t.selectors,xe.keyword),t.values&&n(t.values,xe.number),t.code&&n(t.code,xe.string),t.italic&&n(t.italic,xe.builtin),t.attrs&&n(t.attrs,xe.attribute),s.length===0)return hs(e);s.sort((a,l)=>a.start-l.start||l.end-l.start-(a.end-a.start));let i="",o=0;for(let a of s)a.start<o||(a.start>o&&(i+=hs(e.slice(o,a.start))),i+=`<span class="${a.cls}">${hs(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=hs(e.slice(o))),i}function ey(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Gp[t];return typeof s=="string"&&(s=Gp[s]),s||null}function Qp(e,t){if(!e)return hs(e||"");let s=ey(t);return s?Jv(e,s):hs(e)}var Qs,Gp,xe,Xp=F(()=>{Qs={string:/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(`(?:[^`\\]|\\.)*`)/g,number:/\b(\d+\.?\d*(?:[eE][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+|0o[0-7]+)\b/g,comment1:/(\/\/.*$)/gm,commentHash:/(#.*$)/gm,commentBlock:/(\/\*.*?\*\/)/g},Gp={js:{keywords:/\b(const|let|var|function|class|extends|return|if|else|for|while|do|switch|case|break|continue|new|this|super|import|export|from|default|async|await|yield|try|catch|finally|throw|typeof|instanceof|in|of|delete|void|null|undefined|true|false|NaN|Infinity)\b/g,builtins:/\b(console|window|document|Math|JSON|Array|Object|String|Number|Boolean|Promise|Map|Set|WeakMap|WeakSet|Symbol|Proxy|Reflect|RegExp|Error|Date|parseInt|parseFloat|setTimeout|setInterval|clearTimeout|clearInterval|fetch|require|module|exports|process)\b/g,operators:/(=>|\.\.\.|\?\.|&&|\|\||===|!==|==|!=|>=|<=|>>>=|>>>|>>=|<<=|\+\+|--|[+\-*/%&|^~!<>]=?|\?|:)/g},ts:"js",jsx:"js",tsx:"js",mjs:"js",cjs:"js",vue:"js",py:{keywords:/\b(def|class|return|if|elif|else|for|while|break|continue|pass|import|from|as|with|try|except|finally|raise|yield|lambda|and|or|not|is|in|True|False|None|global|nonlocal|del|assert|async|await)\b/g,builtins:/\b(print|len|range|int|float|str|bool|list|dict|set|tuple|type|isinstance|super|property|staticmethod|classmethod|enumerate|zip|map|filter|sorted|reversed|open|input|hasattr|getattr|setattr|id|hex|oct|bin|abs|max|min|sum|all|any|iter|next)\b/g,decorators:/(@\w+)/g,commentType:"hash"},rb:{keywords:/\b(def|class|module|end|return|if|elsif|else|unless|for|while|until|do|break|next|case|when|begin|rescue|ensure|raise|yield|require|include|extend|attr_accessor|attr_reader|attr_writer|self|super|nil|true|false|and|or|not|then|puts|print)\b/g,commentType:"hash"},go:{keywords:/\b(func|package|import|var|const|type|struct|interface|map|chan|go|select|switch|case|default|if|else|for|range|break|continue|return|defer|fallthrough|nil|true|false|iota)\b/g,builtins:/\b(fmt|make|len|cap|append|copy|delete|close|panic|recover|new|error|string|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64|bool|byte|rune|complex64|complex128)\b/g},rs:{keywords:/\b(fn|let|mut|const|pub|mod|use|struct|enum|impl|trait|where|for|loop|while|if|else|match|return|break|continue|move|ref|self|Self|super|crate|as|in|unsafe|async|await|dyn|true|false|Some|None|Ok|Err)\b/g,builtins:/\b(String|Vec|Box|Rc|Arc|Option|Result|HashMap|HashSet|println|eprintln|format|panic|todo|unimplemented|assert|assert_eq|assert_ne|dbg|cfg|derive|macro_rules)\b/g,macros:/(\w+!)/g},java:{keywords:/\b(class|interface|extends|implements|public|private|protected|static|final|abstract|synchronized|volatile|transient|native|new|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|throws|import|package|this|super|void|null|true|false|instanceof)\b/g,builtins:/\b(System|String|Integer|Long|Double|Float|Boolean|List|ArrayList|Map|HashMap|Set|HashSet|Optional|Stream|Object|Exception|RuntimeException|Thread|Runnable|Override|Deprecated)\b/g},cs:{keywords:/\b(class|struct|interface|enum|record|delegate|event|namespace|using|public|private|protected|internal|static|readonly|const|sealed|abstract|virtual|override|new|return|if|else|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|async|await|yield|var|dynamic|is|as|in|out|ref|params|this|base|null|true|false|void|get|set|init|required|partial|where|select|from|orderby|group|join|let|into)\b/g,builtins:/\b(Console|String|Int32|Int64|Double|Boolean|List|Dictionary|HashSet|Task|IEnumerable|ILogger|IOptions|IFeatures|Exception|Guid|DateTime|TimeSpan|CancellationToken|Action|Func|Span|Memory|ReadOnlySpan)\b/g,attributes:/(\[[\w]+(?:\(.*?\))?\])/g},cpp:{keywords:/\b(class|struct|enum|union|namespace|using|template|typename|public|private|protected|static|const|constexpr|volatile|virtual|override|final|explicit|inline|extern|auto|decltype|new|delete|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|throw|sizeof|alignof|typeid|static_cast|dynamic_cast|reinterpret_cast|const_cast|nullptr|true|false|void|this|operator|friend|noexcept|co_await|co_yield|co_return|concept|requires)\b/g,builtins:/\b(std|string|vector|map|unordered_map|set|array|pair|tuple|shared_ptr|unique_ptr|weak_ptr|optional|variant|any|cout|cin|endl|printf|scanf|malloc|free|sizeof|size_t|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t)\b/g,preprocessor:/(#\s*(?:include|define|undef|if|ifdef|ifndef|else|elif|endif|pragma|error|warning).*$)/gm},c:"cpp",h:"cpp",hpp:"cpp",html:{tags:/(<\/?[\w-]+|>|\/>)/g,attrs:/\b([\w-]+)(?==)/g,commentType:"html",commentHtml:/(<!--[\s\S]*?-->)/g},xml:"html",svg:"html",css:{selectors:/([\w.#\[\]:,>+~*-]+)\s*\{/g,properties:/\b([\w-]+)(?=\s*:)/g,values:/:\s*([^;{}]+)/g,commentType:"block"},scss:"css",less:"css",json:{keys:/("[\w.-]+")\s*:/g,commentType:"none"},yaml:{keys:/([\w.-]+)\s*:/g,commentType:"hash"},yml:"yaml",md:{headings:/^(#{1,6}\s.*)$/gm,bold:/(\*\*[^*]+\*\*|__[^_]+__)/g,italic:/(\*[^*]+\*|_[^_]+_)/g,code:/(`[^`]+`)/g,links:/(\[[^\]]+\]\([^)]+\))/g,commentType:"none"},sh:{keywords:/\b(if|then|else|elif|fi|for|while|do|done|case|esac|function|return|exit|echo|export|local|readonly|unset|set|shift|eval|exec|trap|source|alias|cd|pwd|ls|mkdir|rm|cp|mv|cat|grep|sed|awk|find|xargs|sort|uniq|wc|head|tail|tee|cut|tr|test)\b/g,variables:/(\$\{?\w+\}?|\$\(|\$\{)/g,commentType:"hash"},bash:"sh",zsh:"sh",sql:{keywords:/\b(SELECT|FROM|WHERE|AND|OR|NOT|IN|LIKE|BETWEEN|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|ON|AS|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|ALTER|DROP|TABLE|INDEX|VIEW|TRIGGER|FUNCTION|PROCEDURE|BEGIN|END|IF|ELSE|THEN|CASE|WHEN|DECLARE|EXEC|UNION|ALL|DISTINCT|TOP|EXISTS|NULL|IS|ASC|DESC|PRIMARY|KEY|FOREIGN|REFERENCES|CONSTRAINT|DEFAULT|CHECK|UNIQUE|CASCADE|TRUNCATE|COMMIT|ROLLBACK|GRANT|REVOKE)\b/gi,commentType:"both"},lua:{keywords:/\b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/g,builtins:/\b(print|type|tostring|tonumber|pairs|ipairs|next|select|unpack|error|pcall|xpcall|assert|require|table|string|math|io|os|coroutine|setmetatable|getmetatable|rawget|rawset)\b/g,commentLine:/(--(?!\[).*$)/gm,commentBlock:/(--\[\[[\s\S]*?\]\])/g},php:{keywords:/\b(function|class|interface|trait|extends|implements|public|private|protected|static|final|abstract|const|var|new|return|if|else|elseif|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|use|namespace|require|include|require_once|include_once|echo|print|die|exit|null|true|false|array|list|match|fn|yield|from)\b/g,variables:/(\$\w+)/g},swift:{keywords:/\b(func|class|struct|enum|protocol|extension|let|var|guard|if|else|for|while|repeat|switch|case|default|break|continue|return|throw|try|catch|defer|import|typealias|associatedtype|init|deinit|subscript|operator|precedencegroup|self|Self|super|nil|true|false|is|as|in|inout|throws|rethrows|where|some|any|weak|unowned|lazy|mutating|nonmutating|override|final|required|convenience|optional|dynamic|async|await|actor|nonisolated|isolated|sending|consuming|borrowing)\b/g},kt:{keywords:/\b(fun|class|object|interface|val|var|if|else|when|for|while|do|return|break|continue|throw|try|catch|finally|import|package|as|is|in|out|by|init|constructor|companion|data|sealed|enum|abstract|open|override|private|protected|internal|public|inline|reified|suspend|coroutine|null|true|false|this|super|it|typealias|annotation|lateinit|lazy|get|set)\b/g},dart:{keywords:/\b(class|extends|implements|with|mixin|abstract|sealed|base|interface|final|const|var|late|required|dynamic|void|static|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|rethrow|assert|new|this|super|null|true|false|is|as|in|async|await|yield|import|export|library|part|show|hide|deferred|typedef|enum|extension|on)\b/g},r:{keywords:/\b(if|else|for|while|repeat|function|return|break|next|in|TRUE|FALSE|NULL|NA|Inf|NaN|library|require|source|print|cat|paste|paste0|sprintf|stop|warning|message)\b/g,commentType:"hash"},toml:{keys:/([\w.-]+)\s*=/g,sections:/(\[[\w.]+\])/g,commentType:"hash"},proto:{keywords:/\b(syntax|package|import|option|message|enum|service|rpc|returns|repeated|optional|required|map|oneof|reserved|extensions|extend|group|default|packed|deprecated|java_package|java_outer_classname|optimize_for|cc_enable_arenas|objc_class_prefix|csharp_namespace|swift_prefix|php_class_prefix|php_namespace|ruby_package|string|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|float|double|bool|bytes)\b/g}},xe={keyword:"hl-kw",builtin:"hl-bi",string:"hl-st",number:"hl-nm",comment:"hl-cm",operator:"hl-op",decorator:"hl-dc",macro:"hl-mc",preprocessor:"hl-pp",attribute:"hl-at",tag:"hl-tg",property:"hl-pr",variable:"hl-vr",heading:"hl-hd",bold:"hl-bd",link:"hl-lk",key:"hl-ky",section:"hl-sc"}});function Zp(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
|
|
1951
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=Vue.reactive({}),n=Vue.reactive({}),r=Vue.reactive({}),i=Vue.ref(""),o={},a=!1,l=Vue.computed(()=>{let T=e.currentConversation;return T&&n[T]||null}),c=Vue.computed(()=>{let T=e.currentConversation;return T&&r[T]||""}),d=Vue.computed(()=>!!c.value),u=(T,C)=>{if(C){let R=o[T];if(o[T]=C,R&&R!==C){let B=s[T];B?.terminal?.element&&(C.innerHTML="",C.appendChild(B.terminal.element),Vue.nextTick(()=>{try{B.fitAddon?.fit()}catch{}}))}}},f=T=>{let C=e.currentConversation;C&&(r[C]=T)};async function p(){if(a)return!0;let T=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null;if(!T||!C)try{await Ha("vendor/xterm.min.js"),await Ha("vendor/xterm-addon-fit.min.js"),T=typeof Terminal<"u"?Terminal.Terminal||Terminal:null,C=typeof FitAddon<"u"?FitAddon.FitAddon||FitAddon:null}catch{}return!T||!C?(i.value=t("terminal.xtermNotLoaded"),!1):(a=!0,!0)}function g(){let T=document.documentElement.getAttribute("data-theme")==="dark",R=getComputedStyle(document.documentElement).getPropertyValue("--bg-main").trim()||(T?"#212121":"#ffffff");return T?{background:R,foreground:"#d4d4d4",cursor:"#a0a0a0",selectionBackground:"rgba(255,255,255,0.12)",black:"#3a3a3a",red:"#f48771",green:"#89d185",yellow:"#e5c07b",blue:"#6cb6ff",magenta:"#d670d6",cyan:"#56d4dd",white:"#cccccc",brightBlack:"#555555",brightRed:"#f48771",brightGreen:"#89d185",brightYellow:"#e5c07b",brightBlue:"#6cb6ff",brightMagenta:"#d670d6",brightCyan:"#56d4dd",brightWhite:"#e8e8e8"}:{background:R,foreground:"#383a42",cursor:"#526fff",selectionBackground:"rgba(0,0,0,0.07)",black:"#383a42",red:"#e45649",green:"#50a14f",yellow:"#c18401",blue:"#4078f2",magenta:"#a626a4",cyan:"#0184bc",white:"#a0a1a7",brightBlack:"#4f525e",brightRed:"#e45649",brightGreen:"#50a14f",brightYellow:"#c18401",brightBlue:"#4078f2",brightMagenta:"#a626a4",brightCyan:"#0184bc",brightWhite:"#fafafa"}}async function b(T){if(!T||!e.currentAgent||!await p())return null;let C=Bp(T),R=Terminal.Terminal||Terminal,B=FitAddon.FitAddon||FitAddon,O=new R({cursorBlink:!0,fontSize:13,fontFamily:"'SF Mono', 'Fira Code', 'Consolas', monospace, 'Symbols Nerd Font Mono', 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji'",theme:g(),allowProposedApi:!0}),j=new B;return O.loadAddon(j),O.attachCustomKeyEventHandler(ne=>!((ne.ctrlKey||ne.metaKey)&&ne.key==="v"||(ne.ctrlKey||ne.metaKey)&&ne.key==="c"&&O.hasSelection())),s[C]={created:!0,connected:!1,terminal:O,fitAddon:j},O.onData(ne=>{e.sendWsMessage({type:"terminal_input",agentId:e.currentAgent,conversationId:T,terminalId:C,data:ne,_clientId:e.clientId})}),C}async function h(T,C){let R=s[C];if(!R)return!1;let B=null;for(let O=0;O<10&&(await Vue.nextTick(),B=o[C],!(B||O>=2&&(await new Promise(j=>setTimeout(j,50)),B=o[C],B)));O++);return B?(R.terminal.open(B),R.fitAddon.fit(),e.sendWsMessage({type:"terminal_create",agentId:e.currentAgent,conversationId:T,terminalId:C,cols:R.terminal.cols,rows:R.terminal.rows,_clientId:e.clientId}),!0):(i.value=t("terminal.mountFailed"),R.terminal.dispose(),delete s[C],!1)}let A=!1;async function w(){let T=e.currentConversation;if(!T||!e.currentAgent||n[T]||A)return;A=!0,i.value="";let C=await b(T);if(!C){A=!1;return}n[T]=Vue.reactive({type:"pane",terminalId:C}),r[T]=C,await h(T,C)||(delete n[T],delete r[T]),A=!1}async function S(T){let C=e.currentConversation;if(!C||!r[C])return;let R=r[C],B=await b(C);if(!B)return;let O=Vue.reactive({type:"split",direction:T,ratio:.5,first:{type:"pane",terminalId:R},second:{type:"pane",terminalId:B}}),j=hi(n[C],R,O);if(n[C]=Vue.reactive(j),r[C]=B,!await h(C,B)){let ve=zt(n[C],B);ve&&(n[C]=Vue.reactive(ve)),r[C]=R;return}await Vue.nextTick(),v(C)}function y(T){let C=e.currentConversation;if(!C)return;let R=s[T];R&&(e.sendWsMessage({type:"terminal_close",agentId:e.currentAgent,conversationId:C,terminalId:T,_clientId:e.clientId}),R.terminal?.dispose(),delete s[T],delete o[T]);let B=zt(n[C],T);B?(n[C]=Vue.reactive(B),r[C]===T&&(r[C]=vi(n[C])||""),Vue.nextTick(()=>v(C))):(delete n[C],delete r[C],Vue.nextTick(()=>w()))}function m(){let T=e.currentConversation;!T||!r[T]||y(r[T])}function v(T){if(T||(T=e.currentConversation),!T||!n[T])return;let C=Yn(n[T]);for(let R of C){let B=s[R];if(B?.fitAddon&&B.connected)try{B.fitAddon.fit(),e.sendWsMessage({type:"terminal_resize",agentId:e.currentAgent,conversationId:T,terminalId:R,cols:B.terminal.cols,rows:B.terminal.rows,_clientId:e.clientId})}catch{}}}function E(T){let C=T.detail;if(C)switch(C.type){case"terminal_created":{let R=C.terminalId||C.conversationId,B=s[R];if(B)if(C.success)B.connected=!0,i.value="";else{i.value=C.error||t("terminal.createFailed"),B.terminal?.dispose(),delete s[R];let O=C.conversationId;if(O&&n[O]){let j=zt(n[O],R);j?n[O]=Vue.reactive(j):(delete n[O],delete r[O])}}break}case"terminal_output":{let R=C.terminalId||C.conversationId,B=s[R];B?.terminal&&B.terminal.write(C.data);break}case"terminal_closed":{let R=C.terminalId||C.conversationId,B=s[R];if(B){B.terminal?.dispose(),delete s[R],delete o[R];let O=C.conversationId;if(O&&n[O]){let j=zt(n[O],R);j?(n[O]=Vue.reactive(j),r[O]===R&&(r[O]=vi(n[O])||"")):(delete n[O],delete r[O])}}break}case"terminal_error":{i.value=C.message||t("terminal.error");let R=C.terminalId;if(R&&s[R]&&!s[R].connected){s[R].terminal?.dispose(),delete s[R];let B=C.conversationId;if(B&&n[B]){let O=zt(n[B],R);O?n[B]=Vue.reactive(O):(delete n[B],delete r[B])}}break}}}let V=null;function U(){clearTimeout(V),V=setTimeout(()=>v(),100)}function L(){v()}function D(T){let{conversationId:C}=T.detail;if(C&&n[C]){let R=Yn(n[C]);for(let B of R){let O=s[B];O&&(O.terminal?.dispose(),delete s[B],delete o[B])}delete n[C],delete r[C]}}Vue.onMounted(()=>{window.addEventListener("workbench-message",E),window.addEventListener("resize",U),window.addEventListener("terminal-fit-all",L),window.addEventListener("conversation-deleted",D)}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",E),window.removeEventListener("resize",U),window.removeEventListener("terminal-fit-all",L),window.removeEventListener("conversation-deleted",D),clearTimeout(V);for(let T of Object.keys(s))s[T]?.terminal?.dispose()}),Vue.watch(()=>[e.currentConversation,e.workbenchExpanded],()=>{Vue.nextTick(()=>{if(!e.currentConversation||!e.workbenchExpanded)return;let C=document.querySelector(".terminal-tab");C&&C.offsetParent!==null&&w()})},{immediate:!0}),Vue.watch(()=>e.connectionState,(T,C)=>{if(T==="connected"&&C&&C!=="connected"){for(let R of Object.keys(s))s[R]?.terminal?.dispose(),delete s[R],delete o[R];for(let R of Object.keys(n))delete n[R],delete r[R];Vue.nextTick(()=>w())}}),Vue.watch(()=>e.currentConversation,()=>{Vue.nextTick(()=>v())});let M=null;return Vue.onMounted(()=>{let T=()=>{let R=document.querySelector(".terminal-tab");R&&R.offsetParent!==null&&(w(),v())};M=new MutationObserver(()=>{setTimeout(T,50)});let C=document.querySelector(".workbench-tab-content");C&&M.observe(C,{attributes:!0,subtree:!0,attributeFilter:["style"]})}),Vue.onUnmounted(()=>{M&&M.disconnect()}),{store:e,terminals:s,currentTree:l,currentActivePane:c,hasActivePane:d,terminalError:i,setMountRef:u,activatePane:f,splitPane:S,closeActivePane:m,closePane:y}}}});function yi(e){if(!e)return Gn(Z.default);let t=e.toLowerCase();if(qa[t])return qa[t]();let s=t.lastIndexOf(".");if(s>=0){let n=t.slice(s+1);if(Yp[n])return Yp[n]();let r=t;for(let[i,o]of Object.entries(qa))if(r===i||r.endsWith("/"+i))return o()}return Gn(Z.default)}function bi(e=!1){return Zv(Z.folder,e)}var Z,Gn,Zv,Q,Yp,qa,Na=F(()=>{Z={js:"#F1C40F",ts:"#3178C6",jsx:"#61DAFB",tsx:"#3178C6",py:"#3776AB",rb:"#CC342D",go:"#00ADD8",rs:"#DEA584",java:"#E76F00",cs:"#68217A",cpp:"#00599C",c:"#A8B9CC",html:"#E44D26",css:"#1572B6",scss:"#CF649A",less:"#1D365D",json:"#F1C40F",yaml:"#CB171E",xml:"#E44D26",md:"#519ABA",txt:"#8E8E8E",log:"#8E8E8E",sh:"#4EAA25",ps1:"#012456",sql:"#E38C00",svg:"#FFB13B",img:"#26A69A",git:"#F05032",docker:"#2496ED",config:"#6D8086",lock:"#8E8E8E",env:"#ECD53F",vue:"#41B883",react:"#61DAFB",angular:"#DD0031",svelte:"#FF3E00",php:"#777BB4",swift:"#FA7343",kt:"#7F52FF",lua:"#000080",r:"#276DC3",dart:"#00B4AB",liquid:"#67B6E4",folder:"#90A4AE",folderOpen:"#90A4AE",default:"#8E8E8E"},Gn=e=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.85"/><path d="M14 2v6h6" fill="${e}" opacity="0.5"/></svg>`,Zv=(e,t)=>t?`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M20 6h-8l-2-2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2zm0 12H4V8h16v10z" fill="${e}" opacity="0.9"/></svg>`:`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" fill="${e}" opacity="0.9"/></svg>`,Q=(e,t)=>`<svg width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" fill="${e}" opacity="0.2"/><path d="M14 2v6h6" fill="${e}" opacity="0.15"/><path d="M14 2H6C4.9 2 4 2.9 4 4v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z" stroke="${e}" stroke-width="1.2" fill="none"/><text x="12" y="17" text-anchor="middle" font-size="7" font-weight="700" font-family="system-ui,sans-serif" fill="${e}">${t}</text></svg>`,Yp={js:()=>Q(Z.js,"JS"),mjs:()=>Q(Z.js,"JS"),cjs:()=>Q(Z.js,"JS"),ts:()=>Q(Z.ts,"TS"),mts:()=>Q(Z.ts,"TS"),jsx:()=>Q(Z.jsx,"JSX"),tsx:()=>Q(Z.tsx,"TSX"),html:()=>Q(Z.html,"</>"),htm:()=>Q(Z.html,"</>"),css:()=>Q(Z.css,"CSS"),scss:()=>Q(Z.scss,"SC"),sass:()=>Q(Z.scss,"SA"),less:()=>Q(Z.less,"LS"),vue:()=>Q(Z.vue,"V"),svelte:()=>Q(Z.svelte,"SV"),json:()=>Q(Z.json,"{ }"),yaml:()=>Q(Z.yaml,"YML"),yml:()=>Q(Z.yaml,"YML"),toml:()=>Q(Z.config,"TML"),xml:()=>Q(Z.xml,"</>"),csv:()=>Q(Z.config,"CSV"),md:()=>Q(Z.md,"MD"),markdown:()=>Q(Z.md,"MD"),txt:()=>Gn(Z.txt),log:()=>Gn(Z.log),pdf:()=>Q("#E53935","PDF"),py:()=>Q(Z.py,"PY"),rb:()=>Q(Z.rb,"RB"),go:()=>Q(Z.go,"GO"),rs:()=>Q(Z.rs,"RS"),java:()=>Q(Z.java,"JA"),cs:()=>Q(Z.cs,"C#"),cpp:()=>Q(Z.cpp,"C+"),cc:()=>Q(Z.cpp,"C+"),c:()=>Q(Z.c,"C"),h:()=>Q(Z.c,"H"),hpp:()=>Q(Z.cpp,"H+"),swift:()=>Q(Z.swift,"SW"),kt:()=>Q(Z.kt,"KT"),php:()=>Q(Z.php,"PHP"),lua:()=>Q(Z.lua,"LUA"),r:()=>Q(Z.r,"R"),dart:()=>Q(Z.dart,"DA"),sh:()=>Q(Z.sh,">_"),bash:()=>Q(Z.sh,">_"),zsh:()=>Q(Z.sh,">_"),fish:()=>Q(Z.sh,">_"),ps1:()=>Q(Z.ps1,"PS"),bat:()=>Q(Z.ps1,"BAT"),cmd:()=>Q(Z.ps1,"CMD"),sql:()=>Q(Z.sql,"SQL"),db:()=>Q(Z.sql,"DB"),sqlite:()=>Q(Z.sql,"DB"),svg:()=>Q(Z.svg,"SVG"),png:()=>Q(Z.img,"PNG"),jpg:()=>Q(Z.img,"JPG"),jpeg:()=>Q(Z.img,"JPG"),gif:()=>Q(Z.img,"GIF"),ico:()=>Q(Z.img,"ICO"),webp:()=>Q(Z.img,"WP"),lock:()=>Gn(Z.lock),env:()=>Q(Z.env,"ENV"),ini:()=>Q(Z.config,"INI"),cfg:()=>Q(Z.config,"CFG"),conf:()=>Q(Z.config,"CNF"),liquid:()=>Q(Z.liquid,"LQ"),ejs:()=>Q(Z.html,"EJS"),hbs:()=>Q(Z.html,"HBS"),pug:()=>Q(Z.html,"PUG"),wasm:()=>Q("#654FF0","WA"),proto:()=>Q(Z.config,"PB"),graphql:()=>Q("#E535AB","GQL"),gql:()=>Q("#E535AB","GQL")},qa={dockerfile:()=>Q(Z.docker,"DK"),"docker-compose.yml":()=>Q(Z.docker,"DC"),"docker-compose.yaml":()=>Q(Z.docker,"DC"),".gitignore":()=>Q(Z.git,"GI"),".gitattributes":()=>Q(Z.git,"GA"),".gitmodules":()=>Q(Z.git,"GM"),".env":()=>Q(Z.env,"ENV"),".env.local":()=>Q(Z.env,"ENV"),".env.development":()=>Q(Z.env,"ENV"),".env.production":()=>Q(Z.env,"ENV"),"package.json":()=>Q("#CB3837","NPM"),"package-lock.json":()=>Q("#CB3837","NPM"),"tsconfig.json":()=>Q(Z.ts,"TSC"),eslintrc:()=>Q("#4B32C3","ESL"),".eslintrc.js":()=>Q("#4B32C3","ESL"),".eslintrc.json":()=>Q("#4B32C3","ESL"),".prettierrc":()=>Q("#F7B93E","PR"),makefile:()=>Q(Z.config,"MK"),"cmakelists.txt":()=>Q("#064F8C","CM"),"readme.md":()=>Q(Z.md,"RM"),license:()=>Q("#F5C518","LIC"),"license.md":()=>Q("#F5C518","LIC"),"cargo.toml":()=>Q(Z.rs,"CG"),"go.mod":()=>Q(Z.go,"MOD"),"go.sum":()=>Q(Z.go,"SUM"),gemfile:()=>Q(Z.rb,"GEM"),rakefile:()=>Q(Z.rb,"RK"),"requirements.txt":()=>Q(Z.py,"REQ"),pipfile:()=>Q(Z.py,"PIP"),csproj:()=>Q(Z.cs,"CSP"),".sln":()=>Q(Z.cs,"SLN"),slnx:()=>Q(Z.cs,"SLN")}});function vs(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Jv(e,t){if(!e||!t)return vs(e);let s=[],n=(a,l)=>{if(!a)return;let c=new RegExp(a.source,a.flags),d;for(;(d=c.exec(e))!==null;){let u=d[1]!==void 0?d[1]:d[0],f=d.index+(d[1]!==void 0?d[0].indexOf(d[1]):0);if(s.push({start:f,end:f+u.length,cls:l}),!c.global)break}},r=t.commentType||"slash";if((r==="slash"||r==="both")&&(n(Qs.comment1,xe.comment),n(Qs.commentBlock,xe.comment)),(r==="hash"||r==="both")&&n(Qs.commentHash,xe.comment),r==="html"&&n(t.commentHtml,xe.comment),t.commentLine&&n(t.commentLine,xe.comment),t.commentBlock&&n(t.commentBlock,xe.comment),n(Qs.string,xe.string),n(Qs.number,xe.number),t.keywords&&n(t.keywords,xe.keyword),t.builtins&&n(t.builtins,xe.builtin),t.operators&&n(t.operators,xe.operator),t.decorators&&n(t.decorators,xe.decorator),t.macros&&n(t.macros,xe.macro),t.preprocessor&&n(t.preprocessor,xe.preprocessor),t.attributes&&n(t.attributes,xe.attribute),t.tags&&n(t.tags,xe.tag),t.properties&&n(t.properties,xe.property),t.variables&&n(t.variables,xe.variable),t.headings&&n(t.headings,xe.heading),t.bold&&n(t.bold,xe.bold),t.links&&n(t.links,xe.link),t.keys&&n(t.keys,xe.key),t.sections&&n(t.sections,xe.section),t.selectors&&n(t.selectors,xe.keyword),t.values&&n(t.values,xe.number),t.code&&n(t.code,xe.string),t.italic&&n(t.italic,xe.builtin),t.attrs&&n(t.attrs,xe.attribute),s.length===0)return vs(e);s.sort((a,l)=>a.start-l.start||l.end-l.start-(a.end-a.start));let i="",o=0;for(let a of s)a.start<o||(a.start>o&&(i+=vs(e.slice(o,a.start))),i+=`<span class="${a.cls}">${vs(e.slice(a.start,a.end))}</span>`,o=a.end);return o<e.length&&(i+=vs(e.slice(o))),i}function ey(e){if(!e)return null;let t=e.split(".").pop()?.toLowerCase();if(!t)return null;let s=Gp[t];return typeof s=="string"&&(s=Gp[s]),s||null}function Qp(e,t){if(!e)return vs(e||"");let s=ey(t);return s?Jv(e,s):vs(e)}var Qs,Gp,xe,Xp=F(()=>{Qs={string:/("(?:[^"\\]|\\.)*")|('(?:[^'\\]|\\.)*')|(`(?:[^`\\]|\\.)*`)/g,number:/\b(\d+\.?\d*(?:[eE][+-]?\d+)?|0x[\da-fA-F]+|0b[01]+|0o[0-7]+)\b/g,comment1:/(\/\/.*$)/gm,commentHash:/(#.*$)/gm,commentBlock:/(\/\*.*?\*\/)/g},Gp={js:{keywords:/\b(const|let|var|function|class|extends|return|if|else|for|while|do|switch|case|break|continue|new|this|super|import|export|from|default|async|await|yield|try|catch|finally|throw|typeof|instanceof|in|of|delete|void|null|undefined|true|false|NaN|Infinity)\b/g,builtins:/\b(console|window|document|Math|JSON|Array|Object|String|Number|Boolean|Promise|Map|Set|WeakMap|WeakSet|Symbol|Proxy|Reflect|RegExp|Error|Date|parseInt|parseFloat|setTimeout|setInterval|clearTimeout|clearInterval|fetch|require|module|exports|process)\b/g,operators:/(=>|\.\.\.|\?\.|&&|\|\||===|!==|==|!=|>=|<=|>>>=|>>>|>>=|<<=|\+\+|--|[+\-*/%&|^~!<>]=?|\?|:)/g},ts:"js",jsx:"js",tsx:"js",mjs:"js",cjs:"js",vue:"js",py:{keywords:/\b(def|class|return|if|elif|else|for|while|break|continue|pass|import|from|as|with|try|except|finally|raise|yield|lambda|and|or|not|is|in|True|False|None|global|nonlocal|del|assert|async|await)\b/g,builtins:/\b(print|len|range|int|float|str|bool|list|dict|set|tuple|type|isinstance|super|property|staticmethod|classmethod|enumerate|zip|map|filter|sorted|reversed|open|input|hasattr|getattr|setattr|id|hex|oct|bin|abs|max|min|sum|all|any|iter|next)\b/g,decorators:/(@\w+)/g,commentType:"hash"},rb:{keywords:/\b(def|class|module|end|return|if|elsif|else|unless|for|while|until|do|break|next|case|when|begin|rescue|ensure|raise|yield|require|include|extend|attr_accessor|attr_reader|attr_writer|self|super|nil|true|false|and|or|not|then|puts|print)\b/g,commentType:"hash"},go:{keywords:/\b(func|package|import|var|const|type|struct|interface|map|chan|go|select|switch|case|default|if|else|for|range|break|continue|return|defer|fallthrough|nil|true|false|iota)\b/g,builtins:/\b(fmt|make|len|cap|append|copy|delete|close|panic|recover|new|error|string|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|float32|float64|bool|byte|rune|complex64|complex128)\b/g},rs:{keywords:/\b(fn|let|mut|const|pub|mod|use|struct|enum|impl|trait|where|for|loop|while|if|else|match|return|break|continue|move|ref|self|Self|super|crate|as|in|unsafe|async|await|dyn|true|false|Some|None|Ok|Err)\b/g,builtins:/\b(String|Vec|Box|Rc|Arc|Option|Result|HashMap|HashSet|println|eprintln|format|panic|todo|unimplemented|assert|assert_eq|assert_ne|dbg|cfg|derive|macro_rules)\b/g,macros:/(\w+!)/g},java:{keywords:/\b(class|interface|extends|implements|public|private|protected|static|final|abstract|synchronized|volatile|transient|native|new|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|throws|import|package|this|super|void|null|true|false|instanceof)\b/g,builtins:/\b(System|String|Integer|Long|Double|Float|Boolean|List|ArrayList|Map|HashMap|Set|HashSet|Optional|Stream|Object|Exception|RuntimeException|Thread|Runnable|Override|Deprecated)\b/g},cs:{keywords:/\b(class|struct|interface|enum|record|delegate|event|namespace|using|public|private|protected|internal|static|readonly|const|sealed|abstract|virtual|override|new|return|if|else|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|async|await|yield|var|dynamic|is|as|in|out|ref|params|this|base|null|true|false|void|get|set|init|required|partial|where|select|from|orderby|group|join|let|into)\b/g,builtins:/\b(Console|String|Int32|Int64|Double|Boolean|List|Dictionary|HashSet|Task|IEnumerable|ILogger|IOptions|IFeatures|Exception|Guid|DateTime|TimeSpan|CancellationToken|Action|Func|Span|Memory|ReadOnlySpan)\b/g,attributes:/(\[[\w]+(?:\(.*?\))?\])/g},cpp:{keywords:/\b(class|struct|enum|union|namespace|using|template|typename|public|private|protected|static|const|constexpr|volatile|virtual|override|final|explicit|inline|extern|auto|decltype|new|delete|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|throw|sizeof|alignof|typeid|static_cast|dynamic_cast|reinterpret_cast|const_cast|nullptr|true|false|void|this|operator|friend|noexcept|co_await|co_yield|co_return|concept|requires)\b/g,builtins:/\b(std|string|vector|map|unordered_map|set|array|pair|tuple|shared_ptr|unique_ptr|weak_ptr|optional|variant|any|cout|cin|endl|printf|scanf|malloc|free|sizeof|size_t|int8_t|int16_t|int32_t|int64_t|uint8_t|uint16_t|uint32_t|uint64_t)\b/g,preprocessor:/(#\s*(?:include|define|undef|if|ifdef|ifndef|else|elif|endif|pragma|error|warning).*$)/gm},c:"cpp",h:"cpp",hpp:"cpp",html:{tags:/(<\/?[\w-]+|>|\/>)/g,attrs:/\b([\w-]+)(?==)/g,commentType:"html",commentHtml:/(<!--[\s\S]*?-->)/g},xml:"html",svg:"html",css:{selectors:/([\w.#\[\]:,>+~*-]+)\s*\{/g,properties:/\b([\w-]+)(?=\s*:)/g,values:/:\s*([^;{}]+)/g,commentType:"block"},scss:"css",less:"css",json:{keys:/("[\w.-]+")\s*:/g,commentType:"none"},yaml:{keys:/([\w.-]+)\s*:/g,commentType:"hash"},yml:"yaml",md:{headings:/^(#{1,6}\s.*)$/gm,bold:/(\*\*[^*]+\*\*|__[^_]+__)/g,italic:/(\*[^*]+\*|_[^_]+_)/g,code:/(`[^`]+`)/g,links:/(\[[^\]]+\]\([^)]+\))/g,commentType:"none"},sh:{keywords:/\b(if|then|else|elif|fi|for|while|do|done|case|esac|function|return|exit|echo|export|local|readonly|unset|set|shift|eval|exec|trap|source|alias|cd|pwd|ls|mkdir|rm|cp|mv|cat|grep|sed|awk|find|xargs|sort|uniq|wc|head|tail|tee|cut|tr|test)\b/g,variables:/(\$\{?\w+\}?|\$\(|\$\{)/g,commentType:"hash"},bash:"sh",zsh:"sh",sql:{keywords:/\b(SELECT|FROM|WHERE|AND|OR|NOT|IN|LIKE|BETWEEN|JOIN|LEFT|RIGHT|INNER|OUTER|FULL|ON|AS|GROUP|BY|ORDER|HAVING|LIMIT|OFFSET|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|ALTER|DROP|TABLE|INDEX|VIEW|TRIGGER|FUNCTION|PROCEDURE|BEGIN|END|IF|ELSE|THEN|CASE|WHEN|DECLARE|EXEC|UNION|ALL|DISTINCT|TOP|EXISTS|NULL|IS|ASC|DESC|PRIMARY|KEY|FOREIGN|REFERENCES|CONSTRAINT|DEFAULT|CHECK|UNIQUE|CASCADE|TRUNCATE|COMMIT|ROLLBACK|GRANT|REVOKE)\b/gi,commentType:"both"},lua:{keywords:/\b(and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/g,builtins:/\b(print|type|tostring|tonumber|pairs|ipairs|next|select|unpack|error|pcall|xpcall|assert|require|table|string|math|io|os|coroutine|setmetatable|getmetatable|rawget|rawset)\b/g,commentLine:/(--(?!\[).*$)/gm,commentBlock:/(--\[\[[\s\S]*?\]\])/g},php:{keywords:/\b(function|class|interface|trait|extends|implements|public|private|protected|static|final|abstract|const|var|new|return|if|else|elseif|for|foreach|while|do|switch|case|default|break|continue|try|catch|finally|throw|use|namespace|require|include|require_once|include_once|echo|print|die|exit|null|true|false|array|list|match|fn|yield|from)\b/g,variables:/(\$\w+)/g},swift:{keywords:/\b(func|class|struct|enum|protocol|extension|let|var|guard|if|else|for|while|repeat|switch|case|default|break|continue|return|throw|try|catch|defer|import|typealias|associatedtype|init|deinit|subscript|operator|precedencegroup|self|Self|super|nil|true|false|is|as|in|inout|throws|rethrows|where|some|any|weak|unowned|lazy|mutating|nonmutating|override|final|required|convenience|optional|dynamic|async|await|actor|nonisolated|isolated|sending|consuming|borrowing)\b/g},kt:{keywords:/\b(fun|class|object|interface|val|var|if|else|when|for|while|do|return|break|continue|throw|try|catch|finally|import|package|as|is|in|out|by|init|constructor|companion|data|sealed|enum|abstract|open|override|private|protected|internal|public|inline|reified|suspend|coroutine|null|true|false|this|super|it|typealias|annotation|lateinit|lazy|get|set)\b/g},dart:{keywords:/\b(class|extends|implements|with|mixin|abstract|sealed|base|interface|final|const|var|late|required|dynamic|void|static|return|if|else|for|while|do|switch|case|default|break|continue|try|catch|finally|throw|rethrow|assert|new|this|super|null|true|false|is|as|in|async|await|yield|import|export|library|part|show|hide|deferred|typedef|enum|extension|on)\b/g},r:{keywords:/\b(if|else|for|while|repeat|function|return|break|next|in|TRUE|FALSE|NULL|NA|Inf|NaN|library|require|source|print|cat|paste|paste0|sprintf|stop|warning|message)\b/g,commentType:"hash"},toml:{keys:/([\w.-]+)\s*=/g,sections:/(\[[\w.]+\])/g,commentType:"hash"},proto:{keywords:/\b(syntax|package|import|option|message|enum|service|rpc|returns|repeated|optional|required|map|oneof|reserved|extensions|extend|group|default|packed|deprecated|java_package|java_outer_classname|optimize_for|cc_enable_arenas|objc_class_prefix|csharp_namespace|swift_prefix|php_class_prefix|php_namespace|ruby_package|string|int32|int64|uint32|uint64|sint32|sint64|fixed32|fixed64|sfixed32|sfixed64|float|double|bool|bytes)\b/g}},xe={keyword:"hl-kw",builtin:"hl-bi",string:"hl-st",number:"hl-nm",comment:"hl-cm",operator:"hl-op",decorator:"hl-dc",macro:"hl-mc",preprocessor:"hl-pp",attribute:"hl-at",tag:"hl-tg",property:"hl-pr",variable:"hl-vr",heading:"hl-hd",bold:"hl-bd",link:"hl-lk",key:"hl-ky",section:"hl-sc"}});function Zp(e,t,s){let n=[],r=0,i=0;if(t!=null){let p=t.split(`
|
|
1952
1952
|
`);for(let g=0;g<p.length;g++)n.push({type:"addition",oldNum:"",oldText:"",newNum:g+1,newText:p[g]}),r++;return{lines:n,stats:{additions:r,deletions:0},content:t}}if(!e||e.trim()==="")return{lines:[{type:"context",oldNum:"",oldText:s("git.noDiff"),newNum:"",newText:s("git.noDiff")}],stats:{additions:0,deletions:0},content:""};if(e.includes("Binary files")&&e.includes("differ"))return{lines:[{type:"context",oldNum:"",oldText:s("git.binaryFile"),newNum:"",newText:s("git.binaryFile")}],stats:{additions:0,deletions:0},content:e};let o=e.split(`
|
|
1953
1953
|
`),a=0,l=0,c=!1,d=[],u=[],f=()=>{let p=Math.max(d.length,u.length);for(let g=0;g<p;g++){let b=d[g],h=u[g];b&&h?n.push({type:"modification",oldNum:b.num,oldText:b.text,newNum:h.num,newText:h.text}):b?n.push({type:"deletion",oldNum:b.num,oldText:b.text,newNum:"",newText:""}):h&&n.push({type:"addition",oldNum:"",oldText:"",newNum:h.num,newText:h.text})}d=[],u=[]};for(let p of o){if(p.startsWith("diff --git")||p.startsWith("index ")||p.startsWith("---")||p.startsWith("+++")||p.startsWith("\\"))continue;let g=p.match(/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(g){f(),a=parseInt(g[1]),l=parseInt(g[2]),c=!0,n.push({type:"hunk",oldNum:"\xB7\xB7\xB7",oldText:p,newNum:"\xB7\xB7\xB7",newText:p});continue}if(c)if(p.startsWith("-"))u.length>0&&d.length===0&&f(),d.push({num:a++,text:p.substring(1)}),i++;else if(p.startsWith("+"))u.push({num:l++,text:p.substring(1)}),r++;else{f();let b=p.startsWith(" ")?p.substring(1):p;n.push({type:"context",oldNum:a++,oldText:b,newNum:l++,newText:b})}}return f(),{lines:n,stats:{additions:r,deletions:i},content:e}}var Jp=F(()=>{});function ef(e,t){let{effectiveGitWorkDir:s,gitOperating:n,gitOpFeedback:r,commitMessage:i}=t,o=null,a=null,l=(y,m)=>{o&&clearTimeout(o),r.value={ok:y,message:m},o=setTimeout(()=>{r.value=null},4e3)},c=(y,m)=>{e.currentAgent&&(y.value=!0,m.value="",e.sendWsMessage({type:"git_status",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId}))},d=(y,m={})=>{e.currentAgent&&(n.value=!0,a&&clearTimeout(a),a=setTimeout(()=>{n.value&&(n.value=!1,l(!1,"Operation timed out"))},15e3),e.sendWsMessage({type:y,conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:s.value,_clientId:e.clientId,...m}))};return{showFeedback:l,loadGitStatus:c,gitOp:d,stageFile:y=>d("git_add",{filePath:y}),unstageFile:y=>d("git_reset",{filePath:y}),discardFile:y=>{confirm("Discard changes to "+y+"?")&&d("git_restore",{filePath:y})},stageAll:()=>d("git_add",{addAll:!0}),unstageAll:()=>d("git_reset",{resetAll:!0}),commitChanges:()=>{let y=i.value.trim();y&&d("git_commit",{commitMessage:y})},pushChanges:()=>d("git_push"),handleGitOpResult:(y,m)=>{n.value=!1,a&&(clearTimeout(a),a=null),y.success?(l(!0,y.message||y.operation+" succeeded"),y.operation==="commit"&&(i.value=""),m()):l(!1,y.error||y.operation+" failed")},cleanup:()=>{o&&clearTimeout(o),a&&clearTimeout(a)}}}var tf=F(()=>{});function sf(e,t){let s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref([]),i=Vue.ref(!1),o=Vue.ref(""),a=g=>{i.value=!0,o.value="",e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:g,workDir:t.value,_clientId:e.clientId})};return{folderPickerOpen:s,folderPickerPath:n,folderPickerEntries:r,folderPickerLoading:i,folderPickerSelected:o,openFolderPicker:()=>{s.value=!0,o.value="",i.value=!0;let g=t.value||"";n.value=g,r.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_git_folder_picker",agentId:e.currentAgent,dirPath:g,workDir:t.value,_clientId:e.clientId})},folderPickerNavigateUp:()=>{if(!n.value)return;let g=n.value.includes("\\"),b=g?"\\":"/",h=n.value.replace(/[/\\]$/,"").split(/[/\\]/);if(h.pop(),h.length===0)n.value="",a("");else if(g&&h.length===1&&/^[A-Za-z]:$/.test(h[0]))n.value=h[0]+"\\",a(h[0]+"\\");else{let A=h.join(b);n.value=A,a(A)}},folderPickerSelectItem:g=>{o.value=g.name},folderPickerEnter:g=>{let b=n.value.includes("\\")||/^[A-Z]:/.test(g.name)?"\\":"/",h;n.value?h=n.value.replace(/[/\\]$/,"")+b+g.name:h=g.name+(g.name.endsWith("\\")?"":"\\"),n.value=h,a(h)},confirmFolderPicker:(g,b)=>{let h=n.value;if(h){if(o.value){let A=h.includes("\\")?"\\":"/";h=h.replace(/[/\\]$/,"")+A+o.value}g.value=h,s.value=!1,b()}},handleDirectoryListing:g=>g.conversationId!=="_git_folder_picker"?!1:(i.value=!1,r.value=(g.entries||[]).filter(b=>b.type==="directory").sort((b,h)=>b.name.localeCompare(h.name)),g.dirPath!=null&&(n.value=g.dirPath),!0)}}var nf=F(()=>{});var rf,of=F(()=>{Na();Xp();Jp();tf();nf();rf={name:"GitStatusTab",template:`
|
|
1954
1954
|
<div class="git-status-tab git-three-col">
|
|
@@ -2194,7 +2194,7 @@ ${String(e||"").trim()}
|
|
|
2194
2194
|
</div>
|
|
2195
2195
|
</div>
|
|
2196
2196
|
</div>
|
|
2197
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=H=>H.split(/[/\\]/).pop()||H,n=H=>{let _=H.split(/[/\\]/);return _.pop(),_.join("/")},r=H=>yi(s(H)),i=Vue.ref(null),o=Vue.reactive({staged:!1,modified:!1,untracked:!1}),a=H=>{o[H]=!o[H]},l=Vue.ref(!1),c=Vue.ref(""),d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>e.effectiveWorkDir||""),p=Vue.ref(""),g=Vue.computed(()=>p.value.trim()||f.value),b=Vue.ref(null),h=Vue.ref(!1),A=Vue.ref(!1),w=Vue.ref(""),S=Vue.ref(null),y=Vue.ref([]),m=Vue.ref(null),v=Vue.ref(!0),E=Vue.ref(!1),V=Vue.ref(""),U=Vue.ref(null),L=Vue.ref(0),D=Vue.ref(0),M=H=>H==null||H===""?"":Qp(H,b.value||""),T=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),C=H=>{T.value=Math.max(8,Math.min(24,H)),localStorage.setItem("gitDiffFontSize",T.value.toString())},R=()=>C(T.value+1),B=()=>C(T.value-1),O=H=>{H.deltaY<0?R():H.deltaY>0&&B()},j=Vue.computed(()=>{let H=y.value;if(!H||H.length===0)return[];let _=H.length,J=[],se=0;for(;se<_;){let me=H[se];if(me.type==="addition"||me.type==="deletion"||me.type==="modification"){let z=me.type==="modification"?"modification":me.type,ee=se;for(;se<_&&(H[se].type===z||H[se].type==="modification"&&z!=="modification");)se++;let fe=se-ee;J.push({type:z,top:ee/_*100,height:Math.max(fe/_*100,.5)})}else se++}return J}),ne=H=>{let _=i.value;if(!_)return;let J=H.currentTarget.getBoundingClientRect(),se=(H.clientY-J.top)/J.height;_.scrollTop=se*(_.scrollHeight-_.clientHeight)},ve=Vue.computed(()=>u.value.filter(H=>H.indexStatus!==" "&&H.indexStatus!=="?")),ue=Vue.computed(()=>u.value.filter(H=>H.workTreeStatus==="M"||H.workTreeStatus==="D")),be=Vue.computed(()=>u.value.filter(H=>H.indexStatus==="?"&&H.workTreeStatus==="?")),ie=ef(e,{effectiveGitWorkDir:g,gitOperating:E,gitOpFeedback:U,commitMessage:V}),Ce=()=>ie.loadGitStatus(l,c),x=()=>{Ce()},Y=sf(e,g),oe=H=>bi(H),he=()=>Y.confirmFolderPicker(p,Ce),W=(H,_)=>{b.value=H.path,h.value=_,A.value=!0,w.value="",S.value=null,y.value=[],m.value=null;let J=H.indexStatus==="?"&&H.workTreeStatus==="?";e.sendWsMessage({type:"git_diff",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:g.value,filePath:H.path,staged:_,untracked:J,fullFile:v.value,_clientId:e.clientId})},te=()=>{if(v.value=!v.value,b.value){let H=u.value.find(_=>_.path===b.value);H&&W(H,h.value)}},K=H=>{let _=H.detail;if(_)switch(_.type){case"directory_listing":{if(Y.handleDirectoryListing(_))return;break}case"git_status_result":{if(l.value=!1,_.error){c.value=_.error,d.value=null,u.value=[];return}if(c.value="",d.value=_.branch||"HEAD",u.value=_.files||[],L.value=_.ahead||0,D.value=_.behind||0,b.value){let J=u.value.find(se=>se.path===b.value);if(J){let se=J.indexStatus!==" "&&J.indexStatus!=="?";h.value=se}else b.value=null,S.value=null,y.value=[],m.value=null}break}case"git_diff_result":{if(A.value=!1,_.error){w.value=_.error;return}w.value="";let J=Zp(_.diff,_.newFileContent,t);m.value=J.stats,y.value=J.lines,S.value=J.content;break}case"git_op_result":{ie.handleGitOpResult(_,Ce);break}}};Vue.watch(()=>e.currentAgent,()=>{d.value=null,u.value=[],c.value="",b.value=null,S.value=null,e.currentAgent&&Vue.nextTick(()=>Ce())}),Vue.watch(()=>e.currentConversation,()=>{e.currentAgent&&(b.value=null,S.value=null,y.value=[],m.value=null,Vue.nextTick(()=>Ce()))});let N=()=>Ce();return Vue.onMounted(()=>{window.addEventListener("workbench-message",K),e.currentAgent&&Ce()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",K),ie.cleanup()}),{store:e,getFileName:s,getDirName:n,getFileIconHtml:r,hlLine:M,collapsedGroups:o,toggleGroup:a,gitLoading:l,gitError:c,gitBranch:d,gitFiles:u,gitWorkDir:p,defaultWorkDir:f,changeGitWorkDir:x,stagedFiles:ve,modifiedFiles:ue,untrackedFiles:be,selectedGitFile:b,selectedStaged:h,diffLoading:A,diffError:w,diffContent:S,diffLines:y,diffStats:m,diffFullFile:v,toggleDiffMode:te,scrollMarkers:j,diffScrollContainer:i,onMarkerClick:ne,fontSize:T,zoomIn:R,zoomOut:B,onWheel:O,gitOperating:E,commitMessage:V,gitOpFeedback:U,gitAhead:L,gitBehind:D,stageFile:ie.stageFile,unstageFile:ie.unstageFile,discardFile:ie.discardFile,stageAll:ie.stageAll,unstageAll:ie.unstageAll,commitChanges:ie.commitChanges,pushChanges:ie.pushChanges,selectGitFile:W,refresh:N,folderPickerOpen:Y.folderPickerOpen,folderPickerPath:Y.folderPickerPath,folderPickerEntries:Y.folderPickerEntries,folderPickerLoading:Y.folderPickerLoading,folderPickerSelected:Y.folderPickerSelected,getFolderIcon:oe,openFolderPicker:Y.openFolderPicker,folderPickerNavigateUp:Y.folderPickerNavigateUp,folderPickerSelectItem:Y.folderPickerSelectItem,folderPickerEnter:Y.folderPickerEnter,confirmFolderPicker:he}}}});function af(e){let t=Vue.ref(!1),s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(0),l=Vue.ref(-1),c=Vue.ref(null),d=Vue.ref(null),u=[],f=[],p=()=>{let L=e.value?.cmInstance;if(!L)return;let M=L.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");M&&M.remove()},g=()=>{let L=e.value?.cmInstance;if(!L||f.length===0)return;p();let D=L.getWrapperElement();if(!D.querySelector(".CodeMirror-vscrollbar"))return;let T=L.lineCount();if(T===0)return;let C=document.createElement("div");C.className="cm-find-scrollbar-annotations";for(let R of f){let B=R.from.line/T*100,O=document.createElement("div");O.className="cm-find-scrollbar-tick",O.style.top=B+"%",C.appendChild(O)}D.appendChild(C)},b=()=>{for(let L of u)try{L.clear()}catch{}u=[],f=[],a.value=0,l.value=-1,p()},h=L=>{let D=e.value?.cmInstance;if(!D||!f[L])return;for(let T=0;T<u.length;T++){if(!u[T])continue;let C=u[T].find();C&&(u[T].clear(),u[T]=D.markText(C.from,C.to,{className:"cm-find-highlight"}))}let M=f[L];if(u[L]){let T=u[L].find();T&&(u[L].clear(),u[L]=D.markText(T.from,T.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{D.scrollIntoView({from:M.from,to:M.to},100)},0)},A=()=>{b();let L=e.value?.cmInstance;if(!L||!n.value)return;let D=n.value;if(D.length<3)return;let M=L.getValue(),T=i.value,C=o.value,R=[];try{if(C){let B=T?"g":"gi",O=new RegExp(D,B),j;for(;(j=O.exec(M))!==null;){if(j[0].length===0){O.lastIndex++;continue}let ne=L.posFromIndex(j.index),ve=L.posFromIndex(j.index+j[0].length);if(R.push({from:ne,to:ve}),R.length>1e4)break}}else{let B=T?D:D.toLowerCase(),O=T?M:M.toLowerCase(),j=0;for(;(j=O.indexOf(B,j))!==-1;){let ne=L.posFromIndex(j),ve=L.posFromIndex(j+D.length);if(R.push({from:ne,to:ve}),j+=D.length,R.length>1e4)break}}}catch{return}f=R,a.value=R.length;for(let B of R)u.push(L.markText(B.from,B.to,{className:"cm-find-highlight"}));if(R.length>0){let B=L.getCursor(),O=0;for(let j=0;j<R.length;j++){if(CodeMirror.cmpPos(R[j].from,B)>=0){O=j;break}j===R.length-1&&(O=0)}l.value=O,h(O)}g()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:b,performFind:A,onFindInput:()=>{A()},findNext:()=>{if(f.length===0)return;let L=(l.value+1)%f.length;l.value=L,h(L)},findPrev:()=>{if(f.length===0)return;let L=(l.value-1+f.length)%f.length;l.value=L,h(L)},openFindBar:(L=!1)=>{t.value=!0,s.value=L;let D=e.value?.cmInstance;if(D){let M=D.getSelection();M&&(n.value=M)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&A()})},closeFindBar:()=>{b(),t.value=!1,s.value=!1;let L=e.value?.cmInstance;L&&L.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let L=e.value?.cmInstance;if(!L||f.length===0||l.value<0)return;let D=f[l.value];L.replaceRange(r.value,D.from,D.to),A()},replaceAll:()=>{let L=e.value?.cmInstance;!L||f.length===0||(L.operation(()=>{for(let D=f.length-1;D>=0;D--)L.replaceRange(r.value,f[D].from,f[D].to)}),A())}}}var lf=F(()=>{});function cf(e,t){let{getEffectiveWorkDir:s,treePath:n}=t,r=Vue.reactive(new Set),i=Vue.ref(-1),o=Vue.ref(!1),a=Vue.ref(null),l=null,c=null,d=Vue.ref(!1),u=Vue.ref(""),f=Vue.ref("file"),p=Vue.ref(null),g=Vue.ref(!1),b=Vue.ref(""),h=Vue.ref(null),A=Vue.reactive({visible:!1,x:0,y:0,entry:null}),w=Vue.ref(!1),S=Vue.ref(""),y=Vue.ref(null),m=null,v=Vue.reactive({dragging:null,dropTarget:null}),E=Vue.ref(!1),V=(z,ee)=>{l&&clearTimeout(l),a.value={ok:z,message:ee},l=setTimeout(()=>{a.value=null},4e3)},U=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,V(!1,"Operation timed out"))},15e3)},L=z=>{r.has(z)?r.delete(z):r.add(z)},D=()=>{r.clear(),i.value=-1},M=z=>{f.value=z,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},T=()=>{let z=u.value.trim();if(!z)return;d.value=!1;let ee=n.value||s();if(!ee)return;let fe=ee.includes("\\")?"\\":"/",ae=ee.replace(/[/\\]$/,"")+fe+z;U(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:ae,isDirectory:f.value==="directory",workDir:s(),_clientId:e.clientId})},C=(z,ee)=>{let fe=z.path.split("/").pop();confirm(ee("files.deleteConfirm",{name:fe})+(z.type==="directory"?ee("files.deleteDirHint"):""))&&(U(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],workDir:s(),_clientId:e.clientId}))},R=z=>{let ee=r.size;ee!==0&&confirm(z("files.deleteSelectedConfirm",{count:ee}))&&(U(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},B=()=>{b.value=n.value||s()||"",g.value=!0,Vue.nextTick(()=>h.value?.focus())},O=()=>{let z=b.value.trim();!z||r.size===0||(g.value=!1,U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:z,workDir:s(),_clientId:e.clientId}))},j=(z,ee)=>{let De=z.clientX,$e=z.clientY;De+180>window.innerWidth&&(De=window.innerWidth-180),$e+240>window.innerHeight&&($e=window.innerHeight-240),A.entry=ee,A.x=De,A.y=$e,A.visible=!0},ne=()=>{A.visible=!1};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:f,newFileInput:p,moveDialogVisible:g,moveDestination:b,moveDestInput:h,contextMenu:A,renameDialogVisible:w,renameNewName:S,renameInput:y,dragState:v,externalDropActive:E,showFileOpFeedback:V,toggleSelection:L,clearSelection:D,showNewFileDialog:M,confirmNewFile:T,deleteSingleFile:C,deleteSelected:R,openMoveDialog:B,confirmMove:O,showContextMenu:j,hideContextMenu:ne,ctxRename:()=>{let z=A.entry;ne(),z&&(S.value=z.name,w.value=!0,Vue.nextTick(()=>{let ee=y.value;if(ee)if(ee.focus(),z.type==="file"){let fe=z.name.lastIndexOf(".");fe>0?ee.setSelectionRange(0,fe):ee.select()}else ee.select()}))},confirmRename:()=>{let z=A.entry,ee=S.value.trim();if(!ee||!z||ee===z.name){w.value=!1;return}w.value=!1;let fe=z.path.replace(/\/$/,"").split("/");fe.pop();let ae=fe.join("/")||"/";U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:ae,newName:ee,workDir:s(),_clientId:e.clientId})},ctxCopy:()=>{let z=A.entry;if(ne(),!z)return;let ee=z.path.replace(/\/$/,"").split("/");ee.pop();let fe=ee.join("/")||"/";U(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:fe,workDir:s(),_clientId:e.clientId})},ctxMoveTo:()=>{let z=A.entry;ne(),z&&(r.clear(),r.add(z.path),B())},ctxDelete:z=>{let ee=A.entry;ne(),ee&&C(ee,z)},ctxDownload:()=>{let z=A.entry;ne(),!(!z||z.type!=="file")&&(m=z.path,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:z.path,workDir:s(),_clientId:e.clientId}))},onDragStart:(z,ee)=>{v.dragging=ee,z.dataTransfer.setData("text/plain",ee.path),z.dataTransfer.effectAllowed="move"},onDragOver:(z,ee)=>{if(!v.dragging&&z.dataTransfer.types.includes("Files")){ee.type==="directory"&&(z.dataTransfer.dropEffect="copy",v.dropTarget=ee.path);return}!v.dragging||ee.type!=="directory"||ee.path!==v.dragging.path&&(ee.path.startsWith(v.dragging.path+"/")||(z.dataTransfer.dropEffect="move",v.dropTarget=ee.path))},onDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(v.dropTarget=null)},onDrop:(z,ee,fe)=>{if(v.dropTarget=null,!v.dragging&&z.dataTransfer.files.length>0&&ee.type==="directory"){fe(z.dataTransfer.files,ee.path);return}if(!v.dragging||ee.type!=="directory"){v.dragging=null;return}if(ee.path===v.dragging.path){v.dragging=null;return}U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[v.dragging.path],destination:ee.path,workDir:s(),_clientId:e.clientId}),v.dragging=null},onTreeDragOver:z=>{v.dragging||z.dataTransfer.types.includes("Files")&&(z.dataTransfer.dropEffect="copy",E.value=!0)},onTreeDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(E.value=!1)},onTreeDrop:(z,ee,fe)=>{if(E.value=!1,!v.dragging&&z.dataTransfer.files.length>0){let ae=n.value||ee||s();fe(z.dataTransfer.files,ae)}},handleExternalFileDrop:async(z,ee)=>{if(!ee)return;let fe=[],ae=[];for(let De of z)ae.push(new Promise($e=>{let Oe=new FileReader;Oe.onload=()=>{let je=btoa(new Uint8Array(Oe.result).reduce((Yt,kt)=>Yt+String.fromCharCode(kt),""));fe.push({name:De.name,data:je}),$e()},Oe.onerror=()=>$e(),Oe.readAsArrayBuffer(De)}));await Promise.all(ae),fe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,V(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:fe,dirPath:ee,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(z,ee,fe)=>{o.value=!1,c&&(clearTimeout(c),c=null),V(z.success,z.success?z.message:z.error||"Operation failed"),z.success&&(fe&&ee(fe),(z.operation==="delete"||z.operation==="move")&&(r.clear(),i.value=-1))},getPendingDownload:()=>m,clearPendingDownload:()=>{m=null},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c)}}}var df=F(()=>{});function uf(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=Vue.ref(!1),u=Vue.ref(null),f=Vue.computed(()=>{if(!l.value)return"EXPLORER";let M=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(M[M.length-1]||l.value).toUpperCase()}),p=Vue.computed(()=>l.value?!!c[l.value]?.expanded:!1),g=()=>{if(!l.value)return;let M=c[l.value];M&&(M.expanded=!M.expanded)},b=()=>{for(let M of Object.keys(c))c[M]&&(c[M].expanded=!1)},h=()=>{d.value=!0,Vue.nextTick(()=>u.value?.focus())},A=()=>{d.value=!1,m()},w=()=>{d.value=!1},S=Vue.computed(()=>{let M=[],T=(C,R)=>{let B=c[C];if(!(!B||!B.entries))for(let O of B.entries)M.push({...O,depth:R}),O.type==="directory"&&c[O.path]?.expanded&&T(O.path,R+1)};return l.value&&c[l.value]?.expanded&&T(l.value,0),M}),y=M=>{let T=s(M);c[T]?c[T].loading=!0:c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:M,workDir:t(),_clientId:e.clientId})},m=()=>{let M=a.value.trim();if(!M)return;let T=s(M);l.value=T,Object.keys(c).forEach(C=>delete c[C]),c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:M,workDir:t(),_clientId:e.clientId})},v=M=>{let T=s(M),C=c[T];C?C.loaded?C.expanded=!C.expanded:(C.expanded=!0,y(M)):(c[T]={entries:[],expanded:!0,loaded:!1,loading:!1},y(M))},E=(M,T)=>{let C=S.value,R=C.findIndex(B=>B.path===M.path);if(T&&(T.shiftKey||T.ctrlKey||T.metaKey)){if(T.shiftKey&&r.value>=0&&R>=0){let B=Math.min(r.value,R),O=Math.max(r.value,R);!T.ctrlKey&&!T.metaKey&&n.clear();for(let j=B;j<=O;j++)n.add(C[j].path)}else n.has(M.path)?n.delete(M.path):n.add(M.path);r.value=R;return}n.size>0&&(n.clear(),r.value=-1),M.type==="directory"?v(M.path):i(M.path,M.name),r.value=R},V=M=>{let T=s(M.dirPath);if(M.error){c[T]&&(c[T].loading=!1);return}let C=(M.entries||[]).sort((O,j)=>O.type===j.type?O.name.localeCompare(j.name):O.type==="directory"?-1:1),R=T.replace(/\/$/,""),B=C.map(O=>({...O,path:R+"/"+O.name}));c[T]?(c[T].entries=B,c[T].loaded=!0,c[T].loading=!1):c[T]={entries:B,expanded:!0,loaded:!0,loading:!1},T===l.value&&(a.value=M.dirPath)},U=()=>{Object.keys(c).forEach(M=>delete c[M])};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:S,editingTreePath:d,treePathInputRef:u,rootFolderName:f,rootExpanded:p,toggleRootExpand:g,collapseAll:b,startTreePathEdit:h,confirmTreePath:A,cancelTreePathEdit:w,loadTreeDirectory:y,loadRootDirectory:m,toggleDirectory:v,onTreeItemClick:E,handleDirectoryListing:V,clearTreeNodes:U,initFileBrowser:()=>{let M=t();if(M){let T=s(M);a.value=M,l.value=T,U(),y(M)}},refresh:()=>{l.value&&y(l.value)}}}var pf=F(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return ty.has(s)?"office":sy.has(s)?"pdf":ny.has(s)?"image":"text"}function Et(e){let t=e.lastIndexOf(".");return t<0?!1:ry.has(e.substring(t).toLowerCase())}function iy(e){let t=e.split(".").pop()?.toLowerCase();return{js:"javascript",mjs:"javascript",jsx:"javascript",ts:{name:"javascript",typescript:!0},tsx:{name:"javascript",typescript:!0},json:{name:"javascript",json:!0},py:"python",html:"htmlmixed",htm:"htmlmixed",vue:"htmlmixed",xml:"xml",svg:"xml",css:"css",scss:"css",less:"css",sh:"shell",bash:"shell",zsh:"shell",c:"text/x-csrc",h:"text/x-csrc",cpp:"text/x-c++src",hpp:"text/x-c++src",cs:"text/x-csharp",java:"text/x-java",md:"markdown",markdown:"markdown"}[t]||"text/plain"}function ff(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:w,openGoToLine:S})=>{c=w,d=S},f=(w,S=0)=>{if(!s.value){S<20&&setTimeout(()=>f(w,S+1),100);return}if(!w)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let v=document.createElement("textarea");v.value=w.content||"",v.style.cssText="width:100%;height:100%;border:none;outline:none;resize:none;padding:12px;font-family:monospace;font-size:12px;background:var(--bg-main);color:var(--text-main);white-space:pre;tab-size:4;",v.spellcheck=!1,v.addEventListener("input",()=>{w.content=v.value,w.isDirty=v.value!==w.originalContent}),v.addEventListener("keydown",E=>{(E.ctrlKey||E.metaKey)&&E.key==="s"&&(E.preventDefault(),o())}),s.value.appendChild(v),a.value="";return}let m=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let v=CodeMirror(s.value,{value:w.content||"",mode:iy(w.name),theme:m,lineNumbers:!0,tabSize:4,indentWithTabs:!1,lineWrapping:!1,readOnly:!1,extraKeys:{"Ctrl-S":()=>o(),"Cmd-S":()=>o(),"Ctrl-P":()=>c(),"Cmd-P":()=>c(),"Ctrl-G":()=>d(),"Cmd-G":()=>d(),"Ctrl-F":()=>i(!1),"Cmd-F":()=>i(!1),"Ctrl-R":()=>i(!0),"Cmd-R":()=>i(!0),"Ctrl-H":()=>i(!0),"Cmd-H":()=>i(!0)}});v.on("change",()=>{let V=v.getValue();w.content=V,w.isDirty=V!==w.originalContent}),w.cmInstance=v,v.getWrapperElement().style.fontSize=n.value+"px";let E=e.currentConversation;E&&l[E]?.[w.path]&&v.setHistory(l[E][w.path]),Vue.nextTick(()=>{v.refresh(),setTimeout(()=>v.refresh(),200)}),a.value=""}catch(v){a.value=`Editor error: ${v.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:f,destroyEditor:()=>{r();let w=t.value;w?.cmInstance&&(w.cmInstance.toTextArea&&w.cmInstance.toTextArea(),w.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let w=e.currentConversation;if(!w)return;let S=t.value;S?.cmInstance&&(l[w]||(l[w]={}),l[w][S.path]=S.cmInstance.getHistory())},saveAllUndoHistory:w=>{if(!w)return;let S=t.value;S?.cmInstance&&(l[w]||(l[w]={}),l[w][S.path]=S.cmInstance.getHistory())},cleanupUndoHistory:(w,S)=>{w&&l[w]&&delete l[w][S]},deleteConversationHistory:w=>{delete l[w]}}}var ty,sy,ny,ry,Qn=F(()=>{ty=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),sy=new Set([".pdf"]),ny=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),ry=new Set([".md",".markdown",".mdx"])});function gf(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let p=e.value;return!!(p&&Et(p.name))}),l=Vue.computed(()=>{let p=e.value;if(!p||!Et(p.name)||p.content==null)return"";try{if(typeof marked<"u")return marked.parse(p.content)}catch{}return"<pre>"+(p.content||"")+"</pre>"});function c(){Ye(i.value)}async function d(){await Ye(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let p=e.value;p&&t.value&&s(p)})}return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:p=>{let g=o.value;if(!g||!p._arrayBuffer)return;g.innerHTML="";let b=("."+p.name.split(".").pop()).toLowerCase();if(b===".docx"&&window.docx)window.docx.renderAsync(p._arrayBuffer,g,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0}).catch(h=>{p.previewError=h.message});else if(b===".xlsx"||b===".xls")try{let h=XLSX.read(p._arrayBuffer,{type:"array"}),A=h.SheetNames[0],w=XLSX.utils.sheet_to_html(h.Sheets[A],{editable:!1});g.innerHTML='<div class="xlsx-sheet-tabs">'+h.SheetNames.map((S,y)=>`<button class="xlsx-sheet-tab${y===0?" active":""}" data-idx="${y}">${S}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+w+"</div>",g.querySelectorAll(".xlsx-sheet-tab").forEach(S=>{S.addEventListener("click",()=>{let y=parseInt(S.dataset.idx),m=h.SheetNames[y],v=XLSX.utils.sheet_to_html(h.Sheets[m],{editable:!1});g.querySelector(".xlsx-table-wrap").innerHTML=v,g.querySelectorAll(".xlsx-sheet-tab").forEach(E=>E.classList.remove("active")),S.classList.add("active")})})}catch(h){p.previewError=h.message}else(b===".pptx"||b===".ppt")&&(g.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>")}}}var mf=F(()=>{Nn();Qn()});function hf(e,{getEffectiveWorkDir:t,treePath:s,openFileInTab:n,normalizePath:r,treeRootPath:i,treeNodes:o,loadTreeDirectory:a}){let l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=null,f=Vue.ref(!1),p=Vue.ref(""),g=Vue.ref([]),b=Vue.ref(0),h=Vue.ref(!1),A=Vue.ref(null),w=null,S=Vue.ref(!1),y=Vue.ref(""),m=Vue.ref(null),v=ue=>{!e.currentAgent||!ue.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:ue.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},E=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{v(l.value)},300)},V=()=>{l.value="",c.value=[],d.value=!1},U=ue=>{if(ue.type==="directory"){let be=r(ue.fullPath);i.value=be,s.value=ue.fullPath,Object.keys(o).forEach(ie=>delete o[ie]),a(ue.fullPath),V()}else n(ue.fullPath,ue.name),V()},L=()=>{f.value=!0,p.value="",g.value=[],b.value=0,h.value=!1,Vue.nextTick(()=>A.value?.focus())},D=()=>{f.value=!1,p.value="",g.value=[]},M=()=>{if(w&&clearTimeout(w),!p.value.trim()){g.value=[],h.value=!1;return}h.value=!0,b.value=0,w=setTimeout(()=>{v(p.value)},200)},T=()=>{g.value.length>0&&(b.value=(b.value+1)%g.value.length)},C=()=>{g.value.length>0&&(b.value=(b.value-1+g.value.length)%g.value.length)},R=ue=>{ue.type!=="directory"&&n(ue.fullPath,ue.name),D()},B=()=>{let ue=g.value[b.value];ue&&R(ue)},O=()=>{S.value=!0,y.value="",Vue.nextTick(()=>m.value?.focus())},j=()=>{S.value=!1,y.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:E,clearSearch:V,onSearchResultClick:U,quickOpenVisible:f,quickOpenQuery:p,quickOpenResults:g,quickOpenSelectedIndex:b,quickOpenLoading:h,quickOpenInput:A,openQuickOpen:L,closeQuickOpen:D,onQuickOpenInput:M,quickOpenSelectNext:T,quickOpenSelectPrev:C,quickOpenConfirm:B,quickOpenOpenFile:R,goToLineVisible:S,goToLineValue:y,goToLineInput:m,openGoToLine:O,closeGoToLine:j,goToLineConfirm:ue=>{let be=parseInt(y.value);if(isNaN(be)||be<1)return;let ie=ue.value;if(ie?.cmInstance){let Ce=ie.cmInstance,x=Math.min(be-1,Ce.lineCount()-1);Ce.setCursor({line:x,ch:0}),Ce.scrollIntoView({line:x,ch:0},100),Ce.focus()}j()},handleFileSearchResult:ue=>{let be=ue.results||[];f.value?ue.query&&ue.query.trim()===p.value.trim()&&(g.value=be,h.value=!1,b.value=0):ue.query&&ue.query.trim()===l.value.trim()&&(c.value=be,d.value=!1)}}}var vf=F(()=>{});function yf(e,{getEffectiveWorkDir:t,treePath:s,treeRootPath:n,treeNodes:r,normalizePath:i,loadTreeDirectory:o}){let a=Vue.ref(!1),l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=Vue.ref(""),f=()=>{a.value=!0,u.value="",d.value=!0;let S=s.value||t()||"";l.value=S,c.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})},p=S=>{d.value=!0,u.value="",e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})};return{folderPickerOpen:a,folderPickerPath:l,folderPickerEntries:c,folderPickerLoading:d,folderPickerSelected:u,openFolderPicker:f,folderPickerNavigateUp:()=>{if(!l.value)return;let S=l.value.includes("\\"),y=S?"\\":"/",m=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(m.pop(),m.length===0)l.value="",p("");else if(S&&m.length===1&&/^[A-Za-z]:$/.test(m[0]))l.value=m[0]+"\\",p(m[0]+"\\");else{let v=m.join(y);l.value=v,p(v)}},folderPickerSelectItem:S=>{u.value=S.name},folderPickerEnter:S=>{let y;if(!l.value)y=S.name+(S.name.endsWith("\\")?"":"\\");else{let m=l.value.includes("\\")||/^[A-Z]:/.test(S.name)?"\\":"/";y=l.value.replace(/[/\\]$/,"")+m+S.name}l.value=y,p(y)},confirmFolderPicker:()=>{let S=l.value;if(!S)return;if(u.value){let m=S.includes("\\")?"\\":"/";S=S.replace(/[/\\]$/,"")+m+u.value}s.value=S,a.value=!1;let y=i(S);n.value=y,Object.keys(r).forEach(m=>delete r[m]),r[y]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})},handleFolderPickerListing:S=>{d.value=!1,c.value=(S.entries||[]).filter(y=>y.type==="directory").sort((y,m)=>y.name.localeCompare(m.name)),S.dirPath!=null&&(l.value=S.dirPath)}}}var bf=F(()=>{});function wf(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,debugStatus:u,mdPreviewMode:f,renderOfficeLocal:p,performFind:g,findBarVisible:b,findQuery:h,t:A}){let w=Vue.reactive({}),S=Vue.ref([]),y=Vue.ref(-1),m=Vue.ref(!1),v=Vue.ref(!1),E=Vue.computed(()=>y.value>=0&&y.value<S.value.length?S.value[y.value]:null),V=null,U=()=>{V&&clearTimeout(V),V=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:S.value.map(O=>({path:O.path})),activeIndex:y.value})},500)},L=O=>{O&&(l(O),S.value.length>0?w[O]={files:S.value.map(j=>({path:j.path,name:j.name,content:j.content,originalContent:j.originalContent,isDirty:j.isDirty,fileType:j.fileType})),activeIndex:y.value}:delete w[O],U())},D=O=>{if(i(),!O||!w[O]){S.value=[],y.value=-1;return}let j=w[O];S.value=j.files.map(ne=>({...ne,isDirty:ne.isDirty||!1,originalContent:ne.originalContent||ne.content,cmInstance:null,fileType:ne.fileType||Xs(ne.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null})),y.value=j.activeIndex,Vue.nextTick(()=>{let ne=E.value;ne&&(!ne.fileType||ne.fileType==="text")&&n.value&&r(ne)})};function M(O,j){let ne=t(O),ve=S.value.findIndex(ie=>ie.path===ne);if(ve>=0){y.value!==ve&&(o(),a(),y.value=ve,Vue.nextTick(()=>{let ie=S.value[ve];ie&&ie.content!=null&&(!ie.fileType||ie.fileType==="text")&&r(ie)})),L(e.currentConversation);return}a();let ue=j||ne.split(/[/\\]/).pop(),be=Xs(ue);S.value.push({path:ne,name:ue,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:be,blobUrl:null,previewUrl:null,previewLoading:be!=="text",localPreviewReady:!1,previewError:null}),y.value=S.value.length-1,m.value=!0,be==="text"&&i(),L(e.currentConversation),u.value=`Loading: ${O}`,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O,workDir:s(),_clientId:e.clientId})}let T=O=>{O!==y.value&&(o(),a(),y.value=O,L(e.currentConversation),Vue.nextTick(()=>{let j=S.value[O];j&&(!j.fileType||j.fileType==="text"?Et(j.name)?f.value=!0:j.content!=null&&n.value&&(r(j),b.value&&h.value&&Vue.nextTick(()=>g())):j.fileType==="office"&&j.localPreviewReady&&Vue.nextTick(()=>p(j)))}))},C=O=>{let j=S.value[O];if(j?.isDirty&&!confirm(A("files.unsavedConfirm",{name:j.name})))return;c(e.currentConversation,j.path),j.blobUrl&&URL.revokeObjectURL(j.blobUrl);let ne=O===y.value;S.value.splice(O,1),S.value.length===0?(y.value=-1,i()):y.value>=S.value.length?y.value=S.value.length-1:y.value>O?y.value--:ne&&y.value>=S.value.length&&(y.value=S.value.length-1),L(e.currentConversation),S.value.length>0&&ne&&Vue.nextTick(()=>{let ve=S.value[y.value];ve&&(!ve.fileType||ve.fileType==="text")&&ve.content!=null&&n.value&&r(ve)})};function R(){let O=E.value;!O||!O.isDirty||(v.value=!0,e.sendWsMessage({type:"write_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O.path,content:O.content,workDir:s(),_clientId:e.clientId}))}return{fileTabsMap:w,openFiles:S,activeFileIndex:y,activeFile:E,fileLoading:m,fileSaving:v,saveTabsState:L,restoreTabsState:D,openFileInTab:M,switchToTab:T,closeFileTab:C,saveFile:R,handleConversationDeleted:O=>{let{conversationId:j}=O.detail;j&&(delete w[j],d(j))}}}var kf=F(()=>{Qn()});function Sf({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileLoading:o,fileSaving:a,saveTabsState:l,createEditor:c,openFileInTab:d,tree:u,fp:f,qo:p,ops:g,mdPreviewMode:b,renderOfficeLocal:h,editorContainer:A,debugStatus:w}){return{handleWorkbenchMessage:m=>{let v=m.detail;if(v)switch(v.type){case"directory_listing":{if(v.conversationId==="_folder_picker"){f.handleFolderPickerListing(v);return}u.handleDirectoryListing(v);break}case"file_content":{if(o.value=!1,v.error){w.value=`Error: ${v.error}`,g.clearPendingDownload();let U=t(v.filePath),L=n.value.find(D=>D.path===U);L&&(L.previewLoading=!1,L.previewError=v.error);return}let E=t(v.filePath);if(g.getPendingDownload()&&t(g.getPendingDownload())===E){g.clearPendingDownload();try{if(v.binary){let U=`${location.protocol}//${location.host}/api/preview/${v.fileId}?token=${v.previewToken}`,L=document.createElement("a");L.href=U,L.download=E.split("/").pop()||"download",document.body.appendChild(L),L.click(),document.body.removeChild(L)}else{let U=new Blob([v.content||""],{type:"application/octet-stream"}),L=URL.createObjectURL(U),D=document.createElement("a");D.href=L,D.download=E.split("/").pop()||"download",document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(L)}}catch{}return}let V=n.value.findIndex(U=>U.path===E);if(V>=0){let U=n.value[V];if(v.binary){U.previewLoading=!1;let L=`${location.protocol}//${location.host}/api/preview/${v.fileId}?token=${v.previewToken}`,D=U.fileType||Xs(U.name);U.fileType=D,D==="pdf"||D==="image"?fetch(L).then(M=>M.blob()).then(M=>{U.blobUrl=URL.createObjectURL(M)}).catch(M=>{U.previewError=M.message}):D==="office"&&((localStorage.getItem("officePreviewMode")||"local")==="online"?U.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent(L):fetch(L).then(T=>T.arrayBuffer()).then(T=>{U._arrayBuffer=T,U.localPreviewReady=!0,V===r.value&&Vue.nextTick(()=>h(U))}).catch(T=>{U.previewError=T.message})),l(e.currentConversation);return}U.content=v.content||"",U.originalContent=v.content||"",U.isDirty=!1,l(e.currentConversation),V===r.value&&(Et(U.name)&&b.value||Vue.nextTick(()=>{setTimeout(()=>c(U),100)}))}break}case"file_saved":{if(a.value=!1,v.error)return;let E=t(v.filePath),V=n.value.find(U=>U.path===E);V&&(V.originalContent=V.content,V.isDirty=!1,l(e.currentConversation));break}case"file_search_result":{p.handleFileSearchResult(v);break}case"file_op_result":{g.handleFileOpResult(v,u.loadTreeDirectory,u.treeRootPath.value);break}case"file_tabs_restored":{if(v.openFiles?.length>0&&n.value.length===0){let E=v.activeIndex||0,V=v.openFiles.length;for(let U of v.openFiles){let L=t(U.path),D=L.split("/").pop(),M=Xs(D);n.value.push({path:L,name:D,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:M,blobUrl:null,previewUrl:null,previewLoading:M!=="text",localPreviewReady:!1,previewError:null}),e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:U.path})}r.value=E>=0&&E<V?E:0}break}}},handleOpenFile:m=>{let{filePath:v}=m.detail,E=t(v);d(E,E.split("/").pop())}}}var If=F(()=>{Qn()});var Cf,Af=F(()=>{Na();lf();df();pf();Qn();mf();vf();bf();kf();If();Cf={name:"FilesTab",template:`
|
|
2197
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.inject("t"),s=H=>H.split(/[/\\]/).pop()||H,n=H=>{let _=H.split(/[/\\]/);return _.pop(),_.join("/")},r=H=>yi(s(H)),i=Vue.ref(null),o=Vue.reactive({staged:!1,modified:!1,untracked:!1}),a=H=>{o[H]=!o[H]},l=Vue.ref(!1),c=Vue.ref(""),d=Vue.ref(null),u=Vue.ref([]),f=Vue.computed(()=>e.effectiveWorkDir||""),p=Vue.ref(""),g=Vue.computed(()=>p.value.trim()||f.value),b=Vue.ref(null),h=Vue.ref(!1),A=Vue.ref(!1),w=Vue.ref(""),S=Vue.ref(null),y=Vue.ref([]),m=Vue.ref(null),v=Vue.ref(!0),E=Vue.ref(!1),V=Vue.ref(""),U=Vue.ref(null),L=Vue.ref(0),D=Vue.ref(0),M=H=>H==null||H===""?"":Qp(H,b.value||""),T=Vue.ref(parseInt(localStorage.getItem("gitDiffFontSize"))||12),C=H=>{T.value=Math.max(8,Math.min(24,H)),localStorage.setItem("gitDiffFontSize",T.value.toString())},R=()=>C(T.value+1),B=()=>C(T.value-1),O=H=>{H.deltaY<0?R():H.deltaY>0&&B()},j=Vue.computed(()=>{let H=y.value;if(!H||H.length===0)return[];let _=H.length,J=[],se=0;for(;se<_;){let me=H[se];if(me.type==="addition"||me.type==="deletion"||me.type==="modification"){let z=me.type==="modification"?"modification":me.type,ee=se;for(;se<_&&(H[se].type===z||H[se].type==="modification"&&z!=="modification");)se++;let fe=se-ee;J.push({type:z,top:ee/_*100,height:Math.max(fe/_*100,.5)})}else se++}return J}),ne=H=>{let _=i.value;if(!_)return;let J=H.currentTarget.getBoundingClientRect(),se=(H.clientY-J.top)/J.height;_.scrollTop=se*(_.scrollHeight-_.clientHeight)},ve=Vue.computed(()=>u.value.filter(H=>H.indexStatus!==" "&&H.indexStatus!=="?")),ue=Vue.computed(()=>u.value.filter(H=>H.workTreeStatus==="M"||H.workTreeStatus==="D")),be=Vue.computed(()=>u.value.filter(H=>H.indexStatus==="?"&&H.workTreeStatus==="?")),ie=ef(e,{effectiveGitWorkDir:g,gitOperating:E,gitOpFeedback:U,commitMessage:V}),Ce=()=>ie.loadGitStatus(l,c),x=()=>{Ce()},Y=sf(e,g),oe=H=>bi(H),he=()=>Y.confirmFolderPicker(p,Ce),W=(H,_)=>{b.value=H.path,h.value=_,A.value=!0,w.value="",S.value=null,y.value=[],m.value=null;let J=H.indexStatus==="?"&&H.workTreeStatus==="?";e.sendWsMessage({type:"git_diff",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,workDir:g.value,filePath:H.path,staged:_,untracked:J,fullFile:v.value,_clientId:e.clientId})},te=()=>{if(v.value=!v.value,b.value){let H=u.value.find(_=>_.path===b.value);H&&W(H,h.value)}},K=H=>{let _=H.detail;if(_)switch(_.type){case"directory_listing":{if(Y.handleDirectoryListing(_))return;break}case"git_status_result":{if(l.value=!1,_.error){c.value=_.error,d.value=null,u.value=[];return}if(c.value="",d.value=_.branch||"HEAD",u.value=_.files||[],L.value=_.ahead||0,D.value=_.behind||0,b.value){let J=u.value.find(se=>se.path===b.value);if(J){let se=J.indexStatus!==" "&&J.indexStatus!=="?";h.value=se}else b.value=null,S.value=null,y.value=[],m.value=null}break}case"git_diff_result":{if(A.value=!1,_.error){w.value=_.error;return}w.value="";let J=Zp(_.diff,_.newFileContent,t);m.value=J.stats,y.value=J.lines,S.value=J.content;break}case"git_op_result":{ie.handleGitOpResult(_,Ce);break}}};Vue.watch(()=>e.currentAgent,()=>{d.value=null,u.value=[],c.value="",b.value=null,S.value=null,e.currentAgent&&Vue.nextTick(()=>Ce())}),Vue.watch(()=>e.currentConversation,()=>{e.currentAgent&&(b.value=null,S.value=null,y.value=[],m.value=null,Vue.nextTick(()=>Ce()))});let N=()=>Ce();return Vue.onMounted(()=>{window.addEventListener("workbench-message",K),e.currentAgent&&Ce()}),Vue.onUnmounted(()=>{window.removeEventListener("workbench-message",K),ie.cleanup()}),{store:e,getFileName:s,getDirName:n,getFileIconHtml:r,hlLine:M,collapsedGroups:o,toggleGroup:a,gitLoading:l,gitError:c,gitBranch:d,gitFiles:u,gitWorkDir:p,defaultWorkDir:f,changeGitWorkDir:x,stagedFiles:ve,modifiedFiles:ue,untrackedFiles:be,selectedGitFile:b,selectedStaged:h,diffLoading:A,diffError:w,diffContent:S,diffLines:y,diffStats:m,diffFullFile:v,toggleDiffMode:te,scrollMarkers:j,diffScrollContainer:i,onMarkerClick:ne,fontSize:T,zoomIn:R,zoomOut:B,onWheel:O,gitOperating:E,commitMessage:V,gitOpFeedback:U,gitAhead:L,gitBehind:D,stageFile:ie.stageFile,unstageFile:ie.unstageFile,discardFile:ie.discardFile,stageAll:ie.stageAll,unstageAll:ie.unstageAll,commitChanges:ie.commitChanges,pushChanges:ie.pushChanges,selectGitFile:W,refresh:N,folderPickerOpen:Y.folderPickerOpen,folderPickerPath:Y.folderPickerPath,folderPickerEntries:Y.folderPickerEntries,folderPickerLoading:Y.folderPickerLoading,folderPickerSelected:Y.folderPickerSelected,getFolderIcon:oe,openFolderPicker:Y.openFolderPicker,folderPickerNavigateUp:Y.folderPickerNavigateUp,folderPickerSelectItem:Y.folderPickerSelectItem,folderPickerEnter:Y.folderPickerEnter,confirmFolderPicker:he}}}});function af(e){let t=Vue.ref(!1),s=Vue.ref(!1),n=Vue.ref(""),r=Vue.ref(""),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(0),l=Vue.ref(-1),c=Vue.ref(null),d=Vue.ref(null),u=[],f=[],p=()=>{let L=e.value?.cmInstance;if(!L)return;let M=L.getWrapperElement().querySelector(".cm-find-scrollbar-annotations");M&&M.remove()},g=()=>{let L=e.value?.cmInstance;if(!L||f.length===0)return;p();let D=L.getWrapperElement();if(!D.querySelector(".CodeMirror-vscrollbar"))return;let T=L.lineCount();if(T===0)return;let C=document.createElement("div");C.className="cm-find-scrollbar-annotations";for(let R of f){let B=R.from.line/T*100,O=document.createElement("div");O.className="cm-find-scrollbar-tick",O.style.top=B+"%",C.appendChild(O)}D.appendChild(C)},b=()=>{for(let L of u)try{L.clear()}catch{}u=[],f=[],a.value=0,l.value=-1,p()},h=L=>{let D=e.value?.cmInstance;if(!D||!f[L])return;for(let T=0;T<u.length;T++){if(!u[T])continue;let C=u[T].find();C&&(u[T].clear(),u[T]=D.markText(C.from,C.to,{className:"cm-find-highlight"}))}let M=f[L];if(u[L]){let T=u[L].find();T&&(u[L].clear(),u[L]=D.markText(T.from,T.to,{className:"cm-find-highlight cm-find-current"}))}setTimeout(()=>{D.scrollIntoView({from:M.from,to:M.to},100)},0)},A=()=>{b();let L=e.value?.cmInstance;if(!L||!n.value)return;let D=n.value;if(D.length<3)return;let M=L.getValue(),T=i.value,C=o.value,R=[];try{if(C){let B=T?"g":"gi",O=new RegExp(D,B),j;for(;(j=O.exec(M))!==null;){if(j[0].length===0){O.lastIndex++;continue}let ne=L.posFromIndex(j.index),ve=L.posFromIndex(j.index+j[0].length);if(R.push({from:ne,to:ve}),R.length>1e4)break}}else{let B=T?D:D.toLowerCase(),O=T?M:M.toLowerCase(),j=0;for(;(j=O.indexOf(B,j))!==-1;){let ne=L.posFromIndex(j),ve=L.posFromIndex(j+D.length);if(R.push({from:ne,to:ve}),j+=D.length,R.length>1e4)break}}}catch{return}f=R,a.value=R.length;for(let B of R)u.push(L.markText(B.from,B.to,{className:"cm-find-highlight"}));if(R.length>0){let B=L.getCursor(),O=0;for(let j=0;j<R.length;j++){if(CodeMirror.cmpPos(R[j].from,B)>=0){O=j;break}j===R.length-1&&(O=0)}l.value=O,h(O)}g()};return{findBarVisible:t,replaceBarVisible:s,findQuery:n,replaceQuery:r,findCaseSensitive:i,findUseRegex:o,findMatchCount:a,findMatchIndex:l,findInputRef:c,replaceInputRef:d,clearFindMarkers:b,performFind:A,onFindInput:()=>{A()},findNext:()=>{if(f.length===0)return;let L=(l.value+1)%f.length;l.value=L,h(L)},findPrev:()=>{if(f.length===0)return;let L=(l.value-1+f.length)%f.length;l.value=L,h(L)},openFindBar:(L=!1)=>{t.value=!0,s.value=L;let D=e.value?.cmInstance;if(D){let M=D.getSelection();M&&(n.value=M)}Vue.nextTick(()=>{c.value?.focus(),c.value?.select(),n.value&&A()})},closeFindBar:()=>{b(),t.value=!1,s.value=!1;let L=e.value?.cmInstance;L&&L.focus()},toggleReplaceBar:()=>{s.value=!s.value,s.value&&Vue.nextTick(()=>d.value?.focus())},replaceOne:()=>{let L=e.value?.cmInstance;if(!L||f.length===0||l.value<0)return;let D=f[l.value];L.replaceRange(r.value,D.from,D.to),A()},replaceAll:()=>{let L=e.value?.cmInstance;!L||f.length===0||(L.operation(()=>{for(let D=f.length-1;D>=0;D--)L.replaceRange(r.value,f[D].from,f[D].to)}),A())}}}var lf=F(()=>{});function cf(e,t){let{getEffectiveWorkDir:s,treePath:n}=t,r=Vue.reactive(new Set),i=Vue.ref(-1),o=Vue.ref(!1),a=Vue.ref(null),l=null,c=null,d=Vue.ref(!1),u=Vue.ref(""),f=Vue.ref("file"),p=Vue.ref(null),g=Vue.ref(!1),b=Vue.ref(""),h=Vue.ref(null),A=Vue.reactive({visible:!1,x:0,y:0,entry:null}),w=Vue.ref(!1),S=Vue.ref(""),y=Vue.ref(null),m=null,v=Vue.reactive({dragging:null,dropTarget:null}),E=Vue.ref(!1),V=(z,ee)=>{l&&clearTimeout(l),a.value={ok:z,message:ee},l=setTimeout(()=>{a.value=null},4e3)},U=()=>{o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,V(!1,"Operation timed out"))},15e3)},L=z=>{r.has(z)?r.delete(z):r.add(z)},D=()=>{r.clear(),i.value=-1},M=z=>{f.value=z,u.value="",d.value=!0,Vue.nextTick(()=>p.value?.focus())},T=()=>{let z=u.value.trim();if(!z)return;d.value=!1;let ee=n.value||s();if(!ee)return;let fe=ee.includes("\\")?"\\":"/",ae=ee.replace(/[/\\]$/,"")+fe+z;U(),e.sendWsMessage({type:"create_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:ae,isDirectory:f.value==="directory",workDir:s(),_clientId:e.clientId})},C=(z,ee)=>{let fe=z.path.split("/").pop();confirm(ee("files.deleteConfirm",{name:fe})+(z.type==="directory"?ee("files.deleteDirHint"):""))&&(U(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],workDir:s(),_clientId:e.clientId}))},R=z=>{let ee=r.size;ee!==0&&confirm(z("files.deleteSelectedConfirm",{count:ee}))&&(U(),e.sendWsMessage({type:"delete_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],workDir:s(),_clientId:e.clientId}))},B=()=>{b.value=n.value||s()||"",g.value=!0,Vue.nextTick(()=>h.value?.focus())},O=()=>{let z=b.value.trim();!z||r.size===0||(g.value=!1,U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[...r],destination:z,workDir:s(),_clientId:e.clientId}))},j=(z,ee)=>{let De=z.clientX,$e=z.clientY;De+180>window.innerWidth&&(De=window.innerWidth-180),$e+240>window.innerHeight&&($e=window.innerHeight-240),A.entry=ee,A.x=De,A.y=$e,A.visible=!0},ne=()=>{A.visible=!1};return{selectedPaths:r,lastClickedIndex:i,fileOperating:o,fileOpFeedback:a,newFileDialogVisible:d,newFileName:u,newFileType:f,newFileInput:p,moveDialogVisible:g,moveDestination:b,moveDestInput:h,contextMenu:A,renameDialogVisible:w,renameNewName:S,renameInput:y,dragState:v,externalDropActive:E,showFileOpFeedback:V,toggleSelection:L,clearSelection:D,showNewFileDialog:M,confirmNewFile:T,deleteSingleFile:C,deleteSelected:R,openMoveDialog:B,confirmMove:O,showContextMenu:j,hideContextMenu:ne,ctxRename:()=>{let z=A.entry;ne(),z&&(S.value=z.name,w.value=!0,Vue.nextTick(()=>{let ee=y.value;if(ee)if(ee.focus(),z.type==="file"){let fe=z.name.lastIndexOf(".");fe>0?ee.setSelectionRange(0,fe):ee.select()}else ee.select()}))},confirmRename:()=>{let z=A.entry,ee=S.value.trim();if(!ee||!z||ee===z.name){w.value=!1;return}w.value=!1;let fe=z.path.replace(/\/$/,"").split("/");fe.pop();let ae=fe.join("/")||"/";U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:ae,newName:ee,workDir:s(),_clientId:e.clientId})},ctxCopy:()=>{let z=A.entry;if(ne(),!z)return;let ee=z.path.replace(/\/$/,"").split("/");ee.pop();let fe=ee.join("/")||"/";U(),e.sendWsMessage({type:"copy_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[z.path],destination:fe,workDir:s(),_clientId:e.clientId})},ctxMoveTo:()=>{let z=A.entry;ne(),z&&(r.clear(),r.add(z.path),B())},ctxDelete:z=>{let ee=A.entry;ne(),ee&&C(ee,z)},ctxDownload:()=>{let z=A.entry;ne(),!(!z||z.type!=="file")&&(m=z.path,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:z.path,workDir:s(),_clientId:e.clientId}))},onDragStart:(z,ee)=>{v.dragging=ee,z.dataTransfer.setData("text/plain",ee.path),z.dataTransfer.effectAllowed="move"},onDragOver:(z,ee)=>{if(!v.dragging&&z.dataTransfer.types.includes("Files")){ee.type==="directory"&&(z.dataTransfer.dropEffect="copy",v.dropTarget=ee.path);return}!v.dragging||ee.type!=="directory"||ee.path!==v.dragging.path&&(ee.path.startsWith(v.dragging.path+"/")||(z.dataTransfer.dropEffect="move",v.dropTarget=ee.path))},onDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(v.dropTarget=null)},onDrop:(z,ee,fe)=>{if(v.dropTarget=null,!v.dragging&&z.dataTransfer.files.length>0&&ee.type==="directory"){fe(z.dataTransfer.files,ee.path);return}if(!v.dragging||ee.type!=="directory"){v.dragging=null;return}if(ee.path===v.dragging.path){v.dragging=null;return}U(),e.sendWsMessage({type:"move_files",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,paths:[v.dragging.path],destination:ee.path,workDir:s(),_clientId:e.clientId}),v.dragging=null},onTreeDragOver:z=>{v.dragging||z.dataTransfer.types.includes("Files")&&(z.dataTransfer.dropEffect="copy",E.value=!0)},onTreeDragLeave:z=>{let ee=z.relatedTarget;ee&&z.currentTarget.contains(ee)||(E.value=!1)},onTreeDrop:(z,ee,fe)=>{if(E.value=!1,!v.dragging&&z.dataTransfer.files.length>0){let ae=n.value||ee||s();fe(z.dataTransfer.files,ae)}},handleExternalFileDrop:async(z,ee)=>{if(!ee)return;let fe=[],ae=[];for(let De of z)ae.push(new Promise($e=>{let Oe=new FileReader;Oe.onload=()=>{let je=btoa(new Uint8Array(Oe.result).reduce((Gt,kt)=>Gt+String.fromCharCode(kt),""));fe.push({name:De.name,data:je}),$e()},Oe.onerror=()=>$e(),Oe.readAsArrayBuffer(De)}));await Promise.all(ae),fe.length!==0&&(o.value=!0,c&&clearTimeout(c),c=setTimeout(()=>{o.value&&(o.value=!1,V(!1,"Upload timed out"))},3e4),e.sendWsMessage({type:"upload_to_dir",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,files:fe,dirPath:ee,workDir:s(),_clientId:e.clientId}))},handleFileOpResult:(z,ee,fe)=>{o.value=!1,c&&(clearTimeout(c),c=null),V(z.success,z.success?z.message:z.error||"Operation failed"),z.success&&(fe&&ee(fe),(z.operation==="delete"||z.operation==="move")&&(r.clear(),i.value=-1))},getPendingDownload:()=>m,clearPendingDownload:()=>{m=null},cleanup:()=>{l&&clearTimeout(l),c&&clearTimeout(c)}}}var df=F(()=>{});function uf(e,{getEffectiveWorkDir:t,normalizePath:s,selectedPaths:n,lastClickedIndex:r,openFileInTab:i,clearSelection:o}){let a=Vue.ref(""),l=Vue.ref(""),c=Vue.reactive({}),d=Vue.ref(!1),u=Vue.ref(null),f=Vue.computed(()=>{if(!l.value)return"EXPLORER";let M=l.value.replace(/[\\/]+$/,"").split(/[\\/]/);return(M[M.length-1]||l.value).toUpperCase()}),p=Vue.computed(()=>l.value?!!c[l.value]?.expanded:!1),g=()=>{if(!l.value)return;let M=c[l.value];M&&(M.expanded=!M.expanded)},b=()=>{for(let M of Object.keys(c))c[M]&&(c[M].expanded=!1)},h=()=>{d.value=!0,Vue.nextTick(()=>u.value?.focus())},A=()=>{d.value=!1,m()},w=()=>{d.value=!1},S=Vue.computed(()=>{let M=[],T=(C,R)=>{let B=c[C];if(!(!B||!B.entries))for(let O of B.entries)M.push({...O,depth:R}),O.type==="directory"&&c[O.path]?.expanded&&T(O.path,R+1)};return l.value&&c[l.value]?.expanded&&T(l.value,0),M}),y=M=>{let T=s(M);c[T]?c[T].loading=!0:c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:M,workDir:t(),_clientId:e.clientId})},m=()=>{let M=a.value.trim();if(!M)return;let T=s(M);l.value=T,Object.keys(c).forEach(C=>delete c[C]),c[T]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:M,workDir:t(),_clientId:e.clientId})},v=M=>{let T=s(M),C=c[T];C?C.loaded?C.expanded=!C.expanded:(C.expanded=!0,y(M)):(c[T]={entries:[],expanded:!0,loaded:!1,loading:!1},y(M))},E=(M,T)=>{let C=S.value,R=C.findIndex(B=>B.path===M.path);if(T&&(T.shiftKey||T.ctrlKey||T.metaKey)){if(T.shiftKey&&r.value>=0&&R>=0){let B=Math.min(r.value,R),O=Math.max(r.value,R);!T.ctrlKey&&!T.metaKey&&n.clear();for(let j=B;j<=O;j++)n.add(C[j].path)}else n.has(M.path)?n.delete(M.path):n.add(M.path);r.value=R;return}n.size>0&&(n.clear(),r.value=-1),M.type==="directory"?v(M.path):i(M.path,M.name),r.value=R},V=M=>{let T=s(M.dirPath);if(M.error){c[T]&&(c[T].loading=!1);return}let C=(M.entries||[]).sort((O,j)=>O.type===j.type?O.name.localeCompare(j.name):O.type==="directory"?-1:1),R=T.replace(/\/$/,""),B=C.map(O=>({...O,path:R+"/"+O.name}));c[T]?(c[T].entries=B,c[T].loaded=!0,c[T].loading=!1):c[T]={entries:B,expanded:!0,loaded:!0,loading:!1},T===l.value&&(a.value=M.dirPath)},U=()=>{Object.keys(c).forEach(M=>delete c[M])};return{treePath:a,treeRootPath:l,treeNodes:c,flattenedTree:S,editingTreePath:d,treePathInputRef:u,rootFolderName:f,rootExpanded:p,toggleRootExpand:g,collapseAll:b,startTreePathEdit:h,confirmTreePath:A,cancelTreePathEdit:w,loadTreeDirectory:y,loadRootDirectory:m,toggleDirectory:v,onTreeItemClick:E,handleDirectoryListing:V,clearTreeNodes:U,initFileBrowser:()=>{let M=t();if(M){let T=s(M);a.value=M,l.value=T,U(),y(M)}},refresh:()=>{l.value&&y(l.value)}}}var pf=F(()=>{});function Xs(e){let t=e.lastIndexOf(".");if(t<0)return"text";let s=e.substring(t).toLowerCase();return ty.has(s)?"office":sy.has(s)?"pdf":ny.has(s)?"image":"text"}function Et(e){let t=e.lastIndexOf(".");return t<0?!1:ry.has(e.substring(t).toLowerCase())}function iy(e){let t=e.split(".").pop()?.toLowerCase();return{js:"javascript",mjs:"javascript",jsx:"javascript",ts:{name:"javascript",typescript:!0},tsx:{name:"javascript",typescript:!0},json:{name:"javascript",json:!0},py:"python",html:"htmlmixed",htm:"htmlmixed",vue:"htmlmixed",xml:"xml",svg:"xml",css:"css",scss:"css",less:"css",sh:"shell",bash:"shell",zsh:"shell",c:"text/x-csrc",h:"text/x-csrc",cpp:"text/x-c++src",hpp:"text/x-c++src",cs:"text/x-csharp",java:"text/x-java",md:"markdown",markdown:"markdown"}[t]||"text/plain"}function ff(e,{activeFile:t,editorContainer:s,fontSize:n,clearFindMarkers:r,openFindBar:i,saveFile:o}){let a=Vue.ref(""),l=Vue.reactive({}),c=()=>{},d=()=>{},u=({openQuickOpen:w,openGoToLine:S})=>{c=w,d=S},f=(w,S=0)=>{if(!s.value){S<20&&setTimeout(()=>f(w,S+1),100);return}if(!w)return;if(s.value.innerHTML="",typeof CodeMirror>"u"){let v=document.createElement("textarea");v.value=w.content||"",v.style.cssText="width:100%;height:100%;border:none;outline:none;resize:none;padding:12px;font-family:monospace;font-size:12px;background:var(--bg-main);color:var(--text-main);white-space:pre;tab-size:4;",v.spellcheck=!1,v.addEventListener("input",()=>{w.content=v.value,w.isDirty=v.value!==w.originalContent}),v.addEventListener("keydown",E=>{(E.ctrlKey||E.metaKey)&&E.key==="s"&&(E.preventDefault(),o())}),s.value.appendChild(v),a.value="";return}let m=document.documentElement.getAttribute("data-theme")==="dark"?"material-darker":"default";try{let v=CodeMirror(s.value,{value:w.content||"",mode:iy(w.name),theme:m,lineNumbers:!0,tabSize:4,indentWithTabs:!1,lineWrapping:!1,readOnly:!1,extraKeys:{"Ctrl-S":()=>o(),"Cmd-S":()=>o(),"Ctrl-P":()=>c(),"Cmd-P":()=>c(),"Ctrl-G":()=>d(),"Cmd-G":()=>d(),"Ctrl-F":()=>i(!1),"Cmd-F":()=>i(!1),"Ctrl-R":()=>i(!0),"Cmd-R":()=>i(!0),"Ctrl-H":()=>i(!0),"Cmd-H":()=>i(!0)}});v.on("change",()=>{let V=v.getValue();w.content=V,w.isDirty=V!==w.originalContent}),w.cmInstance=v,v.getWrapperElement().style.fontSize=n.value+"px";let E=e.currentConversation;E&&l[E]?.[w.path]&&v.setHistory(l[E][w.path]),Vue.nextTick(()=>{v.refresh(),setTimeout(()=>v.refresh(),200)}),a.value=""}catch(v){a.value=`Editor error: ${v.message}`}};return{debugStatus:a,undoHistoryMap:l,createEditor:f,destroyEditor:()=>{r();let w=t.value;w?.cmInstance&&(w.cmInstance.toTextArea&&w.cmInstance.toTextArea(),w.cmInstance=null),s.value&&(s.value.innerHTML="")},setKeyBindings:u,saveCurrentUndoHistory:()=>{let w=e.currentConversation;if(!w)return;let S=t.value;S?.cmInstance&&(l[w]||(l[w]={}),l[w][S.path]=S.cmInstance.getHistory())},saveAllUndoHistory:w=>{if(!w)return;let S=t.value;S?.cmInstance&&(l[w]||(l[w]={}),l[w][S.path]=S.cmInstance.getHistory())},cleanupUndoHistory:(w,S)=>{w&&l[w]&&delete l[w][S]},deleteConversationHistory:w=>{delete l[w]}}}var ty,sy,ny,ry,Qn=F(()=>{ty=new Set([".docx",".xlsx",".xls",".pptx",".ppt"]),sy=new Set([".pdf"]),ny=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),ry=new Set([".md",".markdown",".mdx"])});function gf(e,{editorContainer:t,createEditor:s,t:n}){let r=Vue.ref(!0),i=Vue.ref(null),o=Vue.ref(null),a=Vue.computed(()=>{let p=e.value;return!!(p&&Et(p.name))}),l=Vue.computed(()=>{let p=e.value;if(!p||!Et(p.name)||p.content==null)return"";try{if(typeof marked<"u")return marked.parse(p.content)}catch{}return"<pre>"+(p.content||"")+"</pre>"});function c(){Ye(i.value)}async function d(){await Ye(i.value)}function u(){r.value=!1,Vue.nextTick(()=>{let p=e.value;p&&t.value&&s(p)})}return{mdPreviewMode:r,mdPreviewRef:i,officePreviewContainer:o,isActiveMarkdown:a,mdRenderedHtml:l,initMermaid:c,renderMermaidBlocks:d,switchToMdEdit:u,renderOfficeLocal:p=>{let g=o.value;if(!g||!p._arrayBuffer)return;g.innerHTML="";let b=("."+p.name.split(".").pop()).toLowerCase();if(b===".docx"&&window.docx)window.docx.renderAsync(p._arrayBuffer,g,null,{className:"docx-preview-content",inWrapper:!0,ignoreWidth:!1,ignoreHeight:!0}).catch(h=>{p.previewError=h.message});else if(b===".xlsx"||b===".xls")try{let h=XLSX.read(p._arrayBuffer,{type:"array"}),A=h.SheetNames[0],w=XLSX.utils.sheet_to_html(h.Sheets[A],{editable:!1});g.innerHTML='<div class="xlsx-sheet-tabs">'+h.SheetNames.map((S,y)=>`<button class="xlsx-sheet-tab${y===0?" active":""}" data-idx="${y}">${S}</button>`).join("")+'</div><div class="xlsx-table-wrap">'+w+"</div>",g.querySelectorAll(".xlsx-sheet-tab").forEach(S=>{S.addEventListener("click",()=>{let y=parseInt(S.dataset.idx),m=h.SheetNames[y],v=XLSX.utils.sheet_to_html(h.Sheets[m],{editable:!1});g.querySelector(".xlsx-table-wrap").innerHTML=v,g.querySelectorAll(".xlsx-sheet-tab").forEach(E=>E.classList.remove("active")),S.classList.add("active")})})}catch(h){p.previewError=h.message}else(b===".pptx"||b===".ppt")&&(g.innerHTML='<div class="preview-unsupported">'+(n?n("files.pptxNotSupported"):"PowerPoint preview not supported")+"</div>")}}}var mf=F(()=>{Nn();Qn()});function hf(e,{getEffectiveWorkDir:t,treePath:s,openFileInTab:n,normalizePath:r,treeRootPath:i,treeNodes:o,loadTreeDirectory:a}){let l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=null,f=Vue.ref(!1),p=Vue.ref(""),g=Vue.ref([]),b=Vue.ref(0),h=Vue.ref(!1),A=Vue.ref(null),w=null,S=Vue.ref(!1),y=Vue.ref(""),m=Vue.ref(null),v=ue=>{!e.currentAgent||!ue.trim()||e.sendWsMessage({type:"file_search",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,query:ue.trim(),dirPath:s.value||t()||"",_clientId:e.clientId})},E=()=>{if(u&&clearTimeout(u),!l.value.trim()){c.value=[],d.value=!1;return}d.value=!0,u=setTimeout(()=>{v(l.value)},300)},V=()=>{l.value="",c.value=[],d.value=!1},U=ue=>{if(ue.type==="directory"){let be=r(ue.fullPath);i.value=be,s.value=ue.fullPath,Object.keys(o).forEach(ie=>delete o[ie]),a(ue.fullPath),V()}else n(ue.fullPath,ue.name),V()},L=()=>{f.value=!0,p.value="",g.value=[],b.value=0,h.value=!1,Vue.nextTick(()=>A.value?.focus())},D=()=>{f.value=!1,p.value="",g.value=[]},M=()=>{if(w&&clearTimeout(w),!p.value.trim()){g.value=[],h.value=!1;return}h.value=!0,b.value=0,w=setTimeout(()=>{v(p.value)},200)},T=()=>{g.value.length>0&&(b.value=(b.value+1)%g.value.length)},C=()=>{g.value.length>0&&(b.value=(b.value-1+g.value.length)%g.value.length)},R=ue=>{ue.type!=="directory"&&n(ue.fullPath,ue.name),D()},B=()=>{let ue=g.value[b.value];ue&&R(ue)},O=()=>{S.value=!0,y.value="",Vue.nextTick(()=>m.value?.focus())},j=()=>{S.value=!1,y.value=""};return{searchQuery:l,searchResults:c,searchLoading:d,onSearchInput:E,clearSearch:V,onSearchResultClick:U,quickOpenVisible:f,quickOpenQuery:p,quickOpenResults:g,quickOpenSelectedIndex:b,quickOpenLoading:h,quickOpenInput:A,openQuickOpen:L,closeQuickOpen:D,onQuickOpenInput:M,quickOpenSelectNext:T,quickOpenSelectPrev:C,quickOpenConfirm:B,quickOpenOpenFile:R,goToLineVisible:S,goToLineValue:y,goToLineInput:m,openGoToLine:O,closeGoToLine:j,goToLineConfirm:ue=>{let be=parseInt(y.value);if(isNaN(be)||be<1)return;let ie=ue.value;if(ie?.cmInstance){let Ce=ie.cmInstance,x=Math.min(be-1,Ce.lineCount()-1);Ce.setCursor({line:x,ch:0}),Ce.scrollIntoView({line:x,ch:0},100),Ce.focus()}j()},handleFileSearchResult:ue=>{let be=ue.results||[];f.value?ue.query&&ue.query.trim()===p.value.trim()&&(g.value=be,h.value=!1,b.value=0):ue.query&&ue.query.trim()===l.value.trim()&&(c.value=be,d.value=!1)}}}var vf=F(()=>{});function yf(e,{getEffectiveWorkDir:t,treePath:s,treeRootPath:n,treeNodes:r,normalizePath:i,loadTreeDirectory:o}){let a=Vue.ref(!1),l=Vue.ref(""),c=Vue.ref([]),d=Vue.ref(!1),u=Vue.ref(""),f=()=>{a.value=!0,u.value="",d.value=!0;let S=s.value||t()||"";l.value=S,c.value=[],e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})},p=S=>{d.value=!0,u.value="",e.sendWsMessage({type:"list_directory",conversationId:"_folder_picker",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})};return{folderPickerOpen:a,folderPickerPath:l,folderPickerEntries:c,folderPickerLoading:d,folderPickerSelected:u,openFolderPicker:f,folderPickerNavigateUp:()=>{if(!l.value)return;let S=l.value.includes("\\"),y=S?"\\":"/",m=l.value.replace(/[/\\]$/,"").split(/[/\\]/);if(m.pop(),m.length===0)l.value="",p("");else if(S&&m.length===1&&/^[A-Za-z]:$/.test(m[0]))l.value=m[0]+"\\",p(m[0]+"\\");else{let v=m.join(y);l.value=v,p(v)}},folderPickerSelectItem:S=>{u.value=S.name},folderPickerEnter:S=>{let y;if(!l.value)y=S.name+(S.name.endsWith("\\")?"":"\\");else{let m=l.value.includes("\\")||/^[A-Z]:/.test(S.name)?"\\":"/";y=l.value.replace(/[/\\]$/,"")+m+S.name}l.value=y,p(y)},confirmFolderPicker:()=>{let S=l.value;if(!S)return;if(u.value){let m=S.includes("\\")?"\\":"/";S=S.replace(/[/\\]$/,"")+m+u.value}s.value=S,a.value=!1;let y=i(S);n.value=y,Object.keys(r).forEach(m=>delete r[m]),r[y]={entries:[],expanded:!0,loaded:!1,loading:!0},e.sendWsMessage({type:"list_directory",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,dirPath:S,workDir:t(),_clientId:e.clientId})},handleFolderPickerListing:S=>{d.value=!1,c.value=(S.entries||[]).filter(y=>y.type==="directory").sort((y,m)=>y.name.localeCompare(m.name)),S.dirPath!=null&&(l.value=S.dirPath)}}}var bf=F(()=>{});function wf(e,{normalizePath:t,getEffectiveWorkDir:s,editorContainer:n,createEditor:r,destroyEditor:i,clearFindMarkers:o,saveCurrentUndoHistory:a,saveAllUndoHistory:l,cleanupUndoHistory:c,deleteConversationHistory:d,debugStatus:u,mdPreviewMode:f,renderOfficeLocal:p,performFind:g,findBarVisible:b,findQuery:h,t:A}){let w=Vue.reactive({}),S=Vue.ref([]),y=Vue.ref(-1),m=Vue.ref(!1),v=Vue.ref(!1),E=Vue.computed(()=>y.value>=0&&y.value<S.value.length?S.value[y.value]:null),V=null,U=()=>{V&&clearTimeout(V),V=setTimeout(()=>{e.sendWsMessage({type:"update_file_tabs",openFiles:S.value.map(O=>({path:O.path})),activeIndex:y.value})},500)},L=O=>{O&&(l(O),S.value.length>0?w[O]={files:S.value.map(j=>({path:j.path,name:j.name,content:j.content,originalContent:j.originalContent,isDirty:j.isDirty,fileType:j.fileType})),activeIndex:y.value}:delete w[O],U())},D=O=>{if(i(),!O||!w[O]){S.value=[],y.value=-1;return}let j=w[O];S.value=j.files.map(ne=>({...ne,isDirty:ne.isDirty||!1,originalContent:ne.originalContent||ne.content,cmInstance:null,fileType:ne.fileType||Xs(ne.name||""),blobUrl:null,previewUrl:null,previewLoading:!1,localPreviewReady:!1,previewError:null})),y.value=j.activeIndex,Vue.nextTick(()=>{let ne=E.value;ne&&(!ne.fileType||ne.fileType==="text")&&n.value&&r(ne)})};function M(O,j){let ne=t(O),ve=S.value.findIndex(ie=>ie.path===ne);if(ve>=0){y.value!==ve&&(o(),a(),y.value=ve,Vue.nextTick(()=>{let ie=S.value[ve];ie&&ie.content!=null&&(!ie.fileType||ie.fileType==="text")&&r(ie)})),L(e.currentConversation);return}a();let ue=j||ne.split(/[/\\]/).pop(),be=Xs(ue);S.value.push({path:ne,name:ue,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:be,blobUrl:null,previewUrl:null,previewLoading:be!=="text",localPreviewReady:!1,previewError:null}),y.value=S.value.length-1,m.value=!0,be==="text"&&i(),L(e.currentConversation),u.value=`Loading: ${O}`,e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O,workDir:s(),_clientId:e.clientId})}let T=O=>{O!==y.value&&(o(),a(),y.value=O,L(e.currentConversation),Vue.nextTick(()=>{let j=S.value[O];j&&(!j.fileType||j.fileType==="text"?Et(j.name)?f.value=!0:j.content!=null&&n.value&&(r(j),b.value&&h.value&&Vue.nextTick(()=>g())):j.fileType==="office"&&j.localPreviewReady&&Vue.nextTick(()=>p(j)))}))},C=O=>{let j=S.value[O];if(j?.isDirty&&!confirm(A("files.unsavedConfirm",{name:j.name})))return;c(e.currentConversation,j.path),j.blobUrl&&URL.revokeObjectURL(j.blobUrl);let ne=O===y.value;S.value.splice(O,1),S.value.length===0?(y.value=-1,i()):y.value>=S.value.length?y.value=S.value.length-1:y.value>O?y.value--:ne&&y.value>=S.value.length&&(y.value=S.value.length-1),L(e.currentConversation),S.value.length>0&&ne&&Vue.nextTick(()=>{let ve=S.value[y.value];ve&&(!ve.fileType||ve.fileType==="text")&&ve.content!=null&&n.value&&r(ve)})};function R(){let O=E.value;!O||!O.isDirty||(v.value=!0,e.sendWsMessage({type:"write_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:O.path,content:O.content,workDir:s(),_clientId:e.clientId}))}return{fileTabsMap:w,openFiles:S,activeFileIndex:y,activeFile:E,fileLoading:m,fileSaving:v,saveTabsState:L,restoreTabsState:D,openFileInTab:M,switchToTab:T,closeFileTab:C,saveFile:R,handleConversationDeleted:O=>{let{conversationId:j}=O.detail;j&&(delete w[j],d(j))}}}var kf=F(()=>{Qn()});function Sf({store:e,normalizePath:t,getEffectiveWorkDir:s,openFiles:n,activeFileIndex:r,activeFile:i,fileLoading:o,fileSaving:a,saveTabsState:l,createEditor:c,openFileInTab:d,tree:u,fp:f,qo:p,ops:g,mdPreviewMode:b,renderOfficeLocal:h,editorContainer:A,debugStatus:w}){return{handleWorkbenchMessage:m=>{let v=m.detail;if(v)switch(v.type){case"directory_listing":{if(v.conversationId==="_folder_picker"){f.handleFolderPickerListing(v);return}u.handleDirectoryListing(v);break}case"file_content":{if(o.value=!1,v.error){w.value=`Error: ${v.error}`,g.clearPendingDownload();let U=t(v.filePath),L=n.value.find(D=>D.path===U);L&&(L.previewLoading=!1,L.previewError=v.error);return}let E=t(v.filePath);if(g.getPendingDownload()&&t(g.getPendingDownload())===E){g.clearPendingDownload();try{if(v.binary){let U=`${location.protocol}//${location.host}/api/preview/${v.fileId}?token=${v.previewToken}`,L=document.createElement("a");L.href=U,L.download=E.split("/").pop()||"download",document.body.appendChild(L),L.click(),document.body.removeChild(L)}else{let U=new Blob([v.content||""],{type:"application/octet-stream"}),L=URL.createObjectURL(U),D=document.createElement("a");D.href=L,D.download=E.split("/").pop()||"download",document.body.appendChild(D),D.click(),document.body.removeChild(D),URL.revokeObjectURL(L)}}catch{}return}let V=n.value.findIndex(U=>U.path===E);if(V>=0){let U=n.value[V];if(v.binary){U.previewLoading=!1;let L=`${location.protocol}//${location.host}/api/preview/${v.fileId}?token=${v.previewToken}`,D=U.fileType||Xs(U.name);U.fileType=D,D==="pdf"||D==="image"?fetch(L).then(M=>M.blob()).then(M=>{U.blobUrl=URL.createObjectURL(M)}).catch(M=>{U.previewError=M.message}):D==="office"&&((localStorage.getItem("officePreviewMode")||"local")==="online"?U.previewUrl="https://view.officeapps.live.com/op/embed.aspx?src="+encodeURIComponent(L):fetch(L).then(T=>T.arrayBuffer()).then(T=>{U._arrayBuffer=T,U.localPreviewReady=!0,V===r.value&&Vue.nextTick(()=>h(U))}).catch(T=>{U.previewError=T.message})),l(e.currentConversation);return}U.content=v.content||"",U.originalContent=v.content||"",U.isDirty=!1,l(e.currentConversation),V===r.value&&(Et(U.name)&&b.value||Vue.nextTick(()=>{setTimeout(()=>c(U),100)}))}break}case"file_saved":{if(a.value=!1,v.error)return;let E=t(v.filePath),V=n.value.find(U=>U.path===E);V&&(V.originalContent=V.content,V.isDirty=!1,l(e.currentConversation));break}case"file_search_result":{p.handleFileSearchResult(v);break}case"file_op_result":{g.handleFileOpResult(v,u.loadTreeDirectory,u.treeRootPath.value);break}case"file_tabs_restored":{if(v.openFiles?.length>0&&n.value.length===0){let E=v.activeIndex||0,V=v.openFiles.length;for(let U of v.openFiles){let L=t(U.path),D=L.split("/").pop(),M=Xs(D);n.value.push({path:L,name:D,content:null,originalContent:null,isDirty:!1,cmInstance:null,fileType:M,blobUrl:null,previewUrl:null,previewLoading:M!=="text",localPreviewReady:!1,previewError:null}),e.sendWsMessage({type:"read_file",conversationId:e.currentConversation||"_explorer",agentId:e.currentAgent,filePath:U.path})}r.value=E>=0&&E<V?E:0}break}}},handleOpenFile:m=>{let{filePath:v}=m.detail,E=t(v);d(E,E.split("/").pop())}}}var If=F(()=>{Qn()});var Cf,Af=F(()=>{Na();lf();df();pf();Qn();mf();vf();bf();kf();If();Cf={name:"FilesTab",template:`
|
|
2198
2198
|
<div class="files-tab file-two-col" :class="{ 'mobile-editor-view': isMobile && mobileView === 'editor' }" ref="rootEl">
|
|
2199
2199
|
<!-- \u5DE6\u680F: \u5C42\u7EA7\u76EE\u5F55\u6811 -->
|
|
2200
2200
|
<div class="file-col-tree" :class="{ 'drop-active': externalDropActive }" :style="{ flex: '0 0 ' + treePanelWidth + 'px', transition: isTreeResizing ? 'none' : undefined, fontSize: fontSize + 'px' }" @wheel.ctrl.prevent="onWheel"
|
|
@@ -2675,7 +2675,7 @@ ${String(e||"").trim()}
|
|
|
2675
2675
|
<!-- \u62D6\u62FD\u8C03\u6574\u5BBD\u5EA6\u624B\u67C4 -->
|
|
2676
2676
|
<div class="resize-handle" @mousedown="startResize" @touchstart.prevent="startResize" v-if="store.workbenchExpanded"></div>
|
|
2677
2677
|
</div>
|
|
2678
|
-
`,setup(){let e=Pinia.useChatStore(),t=Vue.computed(()=>e.hasCapability("terminal")),s=Vue.computed(()=>e.hasCapability("file_editor")),n=Vue.computed(()=>!1),r=Vue.reactive({}),i=()=>s.value?"files":t.value?"terminal":"files",o=Vue.computed(()=>{let b=e.currentConversation,h=b&&r[b]||"files";return h==="terminal"&&!t.value||(h==="git"||h==="files"||h==="explorer")&&!s.value?i():h==="explorer"?"git":h}),a=b=>{let h=e.currentConversation;h&&(r[h]=b)},l=Vue.ref(0),c=Vue.ref(!1),d=Vue.ref(!1),u=Vue.computed(()=>{if(!e.workbenchExpanded)return{};if(e.workbenchMaximized)return{};if(window.innerWidth<=768)return{};if(!d.value)return c.value?{transition:"none"}:{};let b={width:l.value+"px"};return c.value&&(b.transition="none"),b}),f=b=>{b.preventDefault();let h=b.type==="touchstart",A=h?b.touches[0].clientX:b.clientX;if(c.value=!0,!d.value){let m=b.target.closest(".workbench-panel");m&&(l.value=m.offsetWidth),d.value=!0}let w=l.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let S=m=>{let E=(h?m.touches[0].clientX:m.clientX)-A,V=Math.max(900,window.innerWidth-100);l.value=Math.max(280,Math.min(V,w+E))},y=()=>{c.value=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",y),document.removeEventListener("touchmove",S),document.removeEventListener("touchend",y)};document.addEventListener(h?"touchmove":"mousemove",S),document.addEventListener(h?"touchend":"mouseup",y)},p=()=>{let b=e.currentConversation;b&&s.value&&(r[b]="files")},g=b=>{let{conversationId:h}=b.detail;h&&delete r[h]};return Vue.onMounted(()=>{window.addEventListener("open-file-in-explorer",p),window.addEventListener("conversation-deleted",g)}),Vue.onUnmounted(()=>{window.removeEventListener("open-file-in-explorer",p),window.removeEventListener("conversation-deleted",g)}),{store:e,activeTab:o,setTab:a,hasTerminal:t,hasExplorer:s,hasTasks:n,panelStyle:u,startResize:f}}}});function nt(e){let t=e?.currentTarget;t&&Xn.set(t,{startedOnOverlay:e.target===t,endedOnOverlay:!1})}function rt(e){let t=e?.currentTarget,s=t&&Xn.get(t);s&&(s.endedOnOverlay=e.target===t)}function it(e){let t=e?.currentTarget;t&&Xn.delete(t)}function Ze(e){let t=e?.currentTarget;if(!t)return!1;let s=Xn.get(t),n=e.target===t&&s?.startedOnOverlay===!0&&s.endedOnOverlay===!0;return Xn.delete(t),n}var Xn,
|
|
2678
|
+
`,setup(){let e=Pinia.useChatStore(),t=Vue.computed(()=>e.hasCapability("terminal")),s=Vue.computed(()=>e.hasCapability("file_editor")),n=Vue.computed(()=>!1),r=Vue.reactive({}),i=()=>s.value?"files":t.value?"terminal":"files",o=Vue.computed(()=>{let b=e.currentConversation,h=b&&r[b]||"files";return h==="terminal"&&!t.value||(h==="git"||h==="files"||h==="explorer")&&!s.value?i():h==="explorer"?"git":h}),a=b=>{let h=e.currentConversation;h&&(r[h]=b)},l=Vue.ref(0),c=Vue.ref(!1),d=Vue.ref(!1),u=Vue.computed(()=>{if(!e.workbenchExpanded)return{};if(e.workbenchMaximized)return{};if(window.innerWidth<=768)return{};if(!d.value)return c.value?{transition:"none"}:{};let b={width:l.value+"px"};return c.value&&(b.transition="none"),b}),f=b=>{b.preventDefault();let h=b.type==="touchstart",A=h?b.touches[0].clientX:b.clientX;if(c.value=!0,!d.value){let m=b.target.closest(".workbench-panel");m&&(l.value=m.offsetWidth),d.value=!0}let w=l.value;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let S=m=>{let E=(h?m.touches[0].clientX:m.clientX)-A,V=Math.max(900,window.innerWidth-100);l.value=Math.max(280,Math.min(V,w+E))},y=()=>{c.value=!1,document.body.style.cursor="",document.body.style.userSelect="",document.removeEventListener("mousemove",S),document.removeEventListener("mouseup",y),document.removeEventListener("touchmove",S),document.removeEventListener("touchend",y)};document.addEventListener(h?"touchmove":"mousemove",S),document.addEventListener(h?"touchend":"mouseup",y)},p=()=>{let b=e.currentConversation;b&&s.value&&(r[b]="files")},g=b=>{let{conversationId:h}=b.detail;h&&delete r[h]};return Vue.onMounted(()=>{window.addEventListener("open-file-in-explorer",p),window.addEventListener("conversation-deleted",g)}),Vue.onUnmounted(()=>{window.removeEventListener("open-file-in-explorer",p),window.removeEventListener("conversation-deleted",g)}),{store:e,activeTab:o,setTab:a,hasTerminal:t,hasExplorer:s,hasTasks:n,panelStyle:u,startResize:f}}}});function nt(e){let t=e?.currentTarget;t&&Xn.set(t,{startedOnOverlay:e.target===t,endedOnOverlay:!1})}function rt(e){let t=e?.currentTarget,s=t&&Xn.get(t);s&&(s.endedOnOverlay=e.target===t)}function it(e){let t=e?.currentTarget;t&&Xn.delete(t)}function Ze(e){let t=e?.currentTarget;if(!t)return!1;let s=Xn.get(t),n=e.target===t&&s?.startedOnOverlay===!0&&s.endedOnOverlay===!0;return Xn.delete(t),n}var Xn,ys=F(()=>{Xn=new WeakMap});var wt,xf,Tf=F(()=>{ct();wt=20,xf={name:"DashboardTab",template:`
|
|
2679
2679
|
<div class="db-container">
|
|
2680
2680
|
<!-- Loading state -->
|
|
2681
2681
|
<div v-if="loading && !loaded" class="db-loading">{{ $t('settings.dashboard.loading') }}</div>
|
|
@@ -3223,7 +3223,7 @@ ${String(e||"").trim()}
|
|
|
3223
3223
|
</div>
|
|
3224
3224
|
</form>
|
|
3225
3225
|
</div>
|
|
3226
|
-
`,data(){return{view:"list",editing:null,busy:!1,idStatus:"idle",idErrorKey:"",formError:"",form:this.blankForm(),detail:null,detailLoading:!1,detailError:""}},computed:{vpStore(){return yt()},vpList(){return this.vpStore.vpList},vpDomainSections(){return
|
|
3226
|
+
`,data(){return{view:"list",editing:null,busy:!1,idStatus:"idle",idErrorKey:"",formError:"",form:this.blankForm(),detail:null,detailLoading:!1,detailError:""}},computed:{vpStore(){return yt()},vpList(){return this.vpStore.vpList},vpDomainSections(){return hs(this.vpList)},canSubmit(){return this.busy?!1:this.editing?!0:this.idStatus==="ok"}},methods:{blankForm(){return{vpId:"",displayName:"",displayNameZh:"",description:"",descriptionZh:"",role:"",roleZh:"",traitsRaw:"",modelHint:"",persona:""}},populateFormFrom(e){this.form={vpId:e.vpId,displayName:e.displayName||"",displayNameZh:e.displayNameZh||"",description:e.description||"",descriptionZh:e.descriptionZh||"",role:e.role||"",roleZh:e.roleZh||"",traitsRaw:Array.isArray(e.traits)?e.traits.join(", "):"",modelHint:e.modelHint||"",persona:typeof e.persona=="string"?e.persona:""}},returnToList(e){this.view="list",this.editing=null,this.form=this.blankForm(),this.idStatus="idle",this.idErrorKey="",this.formError=typeof e=="string"?e:"",this.detail=null,this.detailError="",this.detailLoading=!1},startCreate(){this.editing=null,this.form=this.blankForm(),this.idStatus="idle",this.idErrorKey="",this.formError="",this.view="form",this.$nextTick(()=>{let e=this.$refs.vpIdInput;e&&typeof e.focus=="function"&&e.focus()})},async startEdit(e){if(!this.busy&&!(!e||!e.vpId)&&!e.isStock){this.busy=!0,this.formError="";try{let t=await this.chatStore().vpCrudRequest("read",e.vpId);if(!(t&&t.ok&&t.vp)){let n=t&&t.error&&t.error.code||"unknown",r=Zs(n),i=this.$t(r);this.formError=i&&i!==r?i:t&&t.error&&t.error.message||n;return}let s=t.vp;this.editing={vpId:s.vpId},this.populateFormFrom(s),this.idStatus="ok",this.idErrorKey="",this.view="form"}finally{this.busy=!1}}},openInitialEdit(){let e=this.initialEditVpId;if(!e)return;let t=this.vpStore&&this.vpStore.vps&&this.vpStore.vps[e]||(this.vpList||[]).find(s=>s&&s.vpId===e)||{vpId:e};t.isStock||this.startEdit(t)},async startView(e){if(!(this.busy||!e||!e.vpId)){this.busy=!0,this.detailLoading=!0,this.detailError="",this.detail=null,this.view="detail";try{let t=await this.chatStore().vpCrudRequest("read",e.vpId);if(t&&t.ok&&t.vp)this.detail={vpId:t.vp.vpId,displayName:t.vp.displayName||"",displayNameZh:t.vp.displayNameZh||"",description:t.vp.description||"",descriptionZh:t.vp.descriptionZh||"",role:t.vp.role||"",roleZh:t.vp.roleZh||"",traits:Array.isArray(t.vp.traits)?t.vp.traits:[],modelHint:t.vp.modelHint||"",persona:typeof t.vp.persona=="string"?t.vp.persona:"",isStock:!!(t.vp.isStock!=null?t.vp.isStock:e.isStock)};else{let s=t&&t.error&&t.error.code||"unknown",n=Zs(s),r=this.$t(n);this.detailError=r&&r!==n?r:t&&t.error&&t.error.message||s}}catch(t){this.detailError=t&&t.message||this.$t("yeaft.vp.idError.unknown")}finally{this.detailLoading=!1,this.busy=!1}}},editFromDetail(){if(!this.detail||this.detail.isStock)return;let e=this.detail;this.editing={vpId:e.vpId},this.populateFormFrom(e),this.idStatus="ok",this.idErrorKey="",this.formError="",this.view="form"},async confirmDelete(e){if(this.busy||e&&e.isStock)return;let t=e.displayName||e.vpId,s=this.$t("yeaft.vp.crud.deleteConfirm").replace("{name}",t);if(!(typeof window<"u"&&window.confirm&&!window.confirm(s))){this.busy=!0;try{let n=await this.chatStore().vpCrudRequest("delete",e.vpId);if(!n.ok){let r=n.error&&n.error.code||"unknown",i=Zs(r),o=this.$t(i);this.formError=this.$t("yeaft.vp.crud.deleteFailed").replace("{error}",o&&o!==i?o:n.error&&n.error.message||r)}}finally{this.busy=!1}}},onVpIdInput(){this.idStatus==="error"&&(this.idStatus="idle",this.idErrorKey="")},onVpIdBlur(){if(this.editing)return;let e=Mf(this.form.vpId);e.ok?(this.idStatus="ok",this.idErrorKey=""):(this.idStatus="error",this.idErrorKey=Zs(e.reason))},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},parseTraits(e){return e?String(e).split(",").map(t=>t.trim()).filter(Boolean):[]},chatStore(){return window.Pinia&&window.Pinia.useChatStore&&window.Pinia.useChatStore()||typeof Pinia<"u"&&Pinia.useChatStore&&Pinia.useChatStore()},async onSubmit(){if(!this.canSubmit)return;this.busy=!0,this.formError="";let e={vpId:this.form.vpId,displayName:this.form.displayName||this.form.vpId,displayNameZh:this.form.displayNameZh,description:this.form.description,descriptionZh:this.form.descriptionZh,role:this.form.role,roleZh:this.form.roleZh,traits:this.parseTraits(this.form.traitsRaw),modelHint:this.form.modelHint||null,persona:this.form.persona},t=this.editing?"update":"create";try{let s=await this.chatStore().vpCrudRequest(t,e);if(s.ok)this.view="list",this.editing=null,this.form=this.blankForm();else{let n=s.error&&s.error.code||"unknown",r=Zs(n),i=this.$t(r);this.formError=this.$t("yeaft.vp.crud.saveFailed").replace("{error}",i&&i!==r?i:s.error&&s.error.message||n),this.editing==null&&Pf(n)&&(this.idStatus="error",this.idErrorKey=r)}}finally{this.busy=!1}}},mounted(){this.openInitialEdit()},watch:{initialEditVpId(){this.openInitialEdit()},"vpStore.vps":{deep:!0,handler(e){let t=this.detail?.vpId||this.editing?.vpId;t&&(e&&e[t]||(this.view==="detail"||this.view==="form")&&this.returnToList(this.$t("yeaft.vp.crud.view.removed")))}}}}});var Df,Lf=F(()=>{Df={name:"SearchSettingsTab",emits:["message"],template:`
|
|
3227
3227
|
<div class="search-settings-tab">
|
|
3228
3228
|
<div class="settings-section">
|
|
3229
3229
|
<h3 class="settings-section-title">{{ $t('search.settings.backendTitle') }}</h3>
|
|
@@ -3422,7 +3422,7 @@ ${String(e||"").trim()}
|
|
|
3422
3422
|
</div>
|
|
3423
3423
|
</div>
|
|
3424
3424
|
</div>
|
|
3425
|
-
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=S=>n?.proxy?.$t?.(S)??S,i=Vue.computed(()=>s.yeaftMcpServers||[]),o=Vue.computed(()=>s.yeaftMcpRuntime||{connected:!1,toolCount:0,perServer:[]}),a=Vue.computed(()=>!!s.yeaftMcpLoading),l=Vue.computed(()=>{let S=new Map((o.value.perServer||[]).map(y=>[y.name,y]));return i.value.map(y=>{let m=S.get(y.name);return{...y,ready:!!(m&&m.ready),toolCount:m?m.toolCount:0}})}),c=Vue.reactive({name:"",command:"",argsRaw:"",envRaw:""}),d=Vue.ref("");function u(){c.name="",c.command="",c.argsRaw="",c.envRaw="",d.value=""}function f(S){if(!S)return[];let y=[],m=/"([^"]*)"|'([^']*)'|(\S+)/g,v;for(;(v=m.exec(S))!==null;)y.push(v[1]??v[2]??v[3]);return y}function p(S){if(!S)return{};let y={},m=S.split(/\r?\n/);for(let v of m){let E=v.trim();if(!E||E.startsWith("#"))continue;let V=E.indexOf("=");if(V<0)continue;let U=E.slice(0,V).trim(),L=E.slice(V+1);U&&(y[U]=L)}return y}function g(){d.value="";let S=(c.name||"").trim(),y=(c.command||"").trim();if(!S)return d.value=r("settings.mcp.errors.nameRequired"),null;if(!/^[a-z0-9_-]+$/.test(S))return d.value=r("settings.mcp.errors.nameFormat"),null;if(!y)return d.value=r("settings.mcp.errors.commandRequired"),null;let m=[],v={};try{m=f(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{v=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:S,command:y,args:m,env:v}}async function b(){let S=g();if(!S)return;let y=await s.addYeaftMcpServer(S);if(y?.error){t("message",y.error,!0);return}y?.connectError?t("message",r("settings.mcp.connectFailed")+": "+y.connectError,!0):t("message",r("settings.mcp.addSuccess"),!1),u()}async function h(S){if(!S||!confirm(r("settings.mcp.confirmRemove").replace("{name}",S)))return;let y=await s.removeYeaftMcpServer(S);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.removeSuccess"),!1)}async function A(S){let y=await s.reloadYeaftMcpServer(S);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}async function w(){let S=await s.reloadYeaftMcpServer(null);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}return Vue.onMounted(()=>{s.loadYeaftMcpServers()}),{servers:i,runtime:o,loading:a,serversWithStatus:l,form:c,formError:d,resetForm:u,addServer:b,removeOne:h,reloadOne:A,reloadAll:w}}}});var ki,Wa=F(()=>{ct();ma();ya();
|
|
3425
|
+
`,setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Vue.getCurrentInstance(),r=S=>n?.proxy?.$t?.(S)??S,i=Vue.computed(()=>s.yeaftMcpServers||[]),o=Vue.computed(()=>s.yeaftMcpRuntime||{connected:!1,toolCount:0,perServer:[]}),a=Vue.computed(()=>!!s.yeaftMcpLoading),l=Vue.computed(()=>{let S=new Map((o.value.perServer||[]).map(y=>[y.name,y]));return i.value.map(y=>{let m=S.get(y.name);return{...y,ready:!!(m&&m.ready),toolCount:m?m.toolCount:0}})}),c=Vue.reactive({name:"",command:"",argsRaw:"",envRaw:""}),d=Vue.ref("");function u(){c.name="",c.command="",c.argsRaw="",c.envRaw="",d.value=""}function f(S){if(!S)return[];let y=[],m=/"([^"]*)"|'([^']*)'|(\S+)/g,v;for(;(v=m.exec(S))!==null;)y.push(v[1]??v[2]??v[3]);return y}function p(S){if(!S)return{};let y={},m=S.split(/\r?\n/);for(let v of m){let E=v.trim();if(!E||E.startsWith("#"))continue;let V=E.indexOf("=");if(V<0)continue;let U=E.slice(0,V).trim(),L=E.slice(V+1);U&&(y[U]=L)}return y}function g(){d.value="";let S=(c.name||"").trim(),y=(c.command||"").trim();if(!S)return d.value=r("settings.mcp.errors.nameRequired"),null;if(!/^[a-z0-9_-]+$/.test(S))return d.value=r("settings.mcp.errors.nameFormat"),null;if(!y)return d.value=r("settings.mcp.errors.commandRequired"),null;let m=[],v={};try{m=f(c.argsRaw)}catch{return d.value=r("settings.mcp.errors.argsParse"),null}try{v=p(c.envRaw)}catch{return d.value=r("settings.mcp.errors.envParse"),null}return{name:S,command:y,args:m,env:v}}async function b(){let S=g();if(!S)return;let y=await s.addYeaftMcpServer(S);if(y?.error){t("message",y.error,!0);return}y?.connectError?t("message",r("settings.mcp.connectFailed")+": "+y.connectError,!0):t("message",r("settings.mcp.addSuccess"),!1),u()}async function h(S){if(!S||!confirm(r("settings.mcp.confirmRemove").replace("{name}",S)))return;let y=await s.removeYeaftMcpServer(S);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.removeSuccess"),!1)}async function A(S){let y=await s.reloadYeaftMcpServer(S);y?.error?t("message",y.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}async function w(){let S=await s.reloadYeaftMcpServer(null);S?.error?t("message",S.error,!0):t("message",r("settings.mcp.reloadSuccess"),!1)}return Vue.onMounted(()=>{s.loadYeaftMcpServers()}),{servers:i,runtime:o,loading:a,serversWithStatus:l,form:c,formError:d,resetForm:u,addServer:b,removeOne:h,reloadOne:A,reloadAll:w}}}});var ki,Wa=F(()=>{ct();ma();ya();ys();Tf();Ef();Lf();Vf();ki={name:"SettingsPanel",components:{DashboardTab:xf,VpCrudPanel:_f,SearchSettingsTab:Df,McpTab:$f},props:{visible:Boolean,initialTab:{type:String,default:""},initialSubTab:{type:String,default:""},initialEditVpId:{type:String,default:""}},emits:["close"],template:`
|
|
3426
3426
|
<div
|
|
3427
3427
|
class="settings-overlay"
|
|
3428
3428
|
v-if="visible"
|
|
@@ -4131,7 +4131,7 @@ ${String(e||"").trim()}
|
|
|
4131
4131
|
</div>
|
|
4132
4132
|
</div>
|
|
4133
4133
|
</div>
|
|
4134
|
-
`,props:{visible:{type:Boolean,default:!1},modelValue:{type:Array,default:()=>[]}},emits:["close","update:modelValue"],setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Vue.ref(null),i=Vue.computed(()=>n.role==="admin"),o=Vue.computed(()=>(s.locale||"zh-CN")==="zh-CN"),a=Vue.ref(null),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref(null),u={id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",nameEn:"Custom",icon:"\u2728",order:99},f=Vue.computed(()=>{if(!a.value)return null;let x=ut[a.value];return x||s.customExpertRoles.find(Y=>Y.id===a.value)||null}),p=Vue.computed(()=>{let x=f.value;return x?`${x.title}\xB7${x.name}`:""}),g=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),b=Vue.computed(()=>!a.value||ut[a.value]?null:s.customExpertRoles.find(x=>x.id===a.value)||null),h=Vue.ref(new Set([Xc])),A=Vue.computed(()=>e.modelValue),w=Vue.computed(()=>Zc(i.value)),S=Vue.computed(()=>{let x=[...w.value];return x.push({id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",icon:"\u2728",order:99}),x}),y=Vue.computed(()=>h.value.has("custom")),m=Vue.computed(()=>new Set(w.value.map(x=>x.id))),v=Vue.computed(()=>Gc().filter(x=>m.value.has(x.teamId)&&h.value.has(x.teamId)));Vue.watch(()=>e.visible,x=>{x&&(s.fetchExpertRoleDefinitions(),s.fetchCustomExpertRoles())});let E=x=>{a.value=x,ut[x]&&s.fetchExpertRoleDefinitions()},V=x=>{c.value=x,l.value=!0},U=()=>{s.fetchCustomExpertRoles()},L=x=>{d.value=x},D=async()=>{if(d.value){try{let x=d.value.id,Y=A.value.filter(oe=>oe.role!==x);Y.length!==A.value.length&&t("update:modelValue",Y),await s.deleteCustomExpertRole(x)}catch{}d.value=null}},M=x=>{if(!(h.value.size===1&&h.value.has(x)))if(h.value=new Set([x]),x==="custom"){let Y=new Set(s.customExpertRoles.map(he=>he.id)),oe=A.value.filter(he=>Y.has(he.role));oe.length!==A.value.length&&t("update:modelValue",oe)}else{let Y=A.value.filter(oe=>{let he=ut[oe.role];return he&&he.group===x});Y.length!==A.value.length&&t("update:modelValue",Y)}},T=(x,Y)=>A.value.some(oe=>oe.role===x&&oe.action===(Y||null)),C=x=>A.value.some(Y=>Y.role===x&&!Y.action),R=x=>A.value.some(Y=>Y.role===x),B=x=>A.value.length>=
|
|
4134
|
+
`,props:{visible:{type:Boolean,default:!1},modelValue:{type:Array,default:()=>[]}},emits:["close","update:modelValue"],setup(e,{emit:t}){let s=Pinia.useChatStore(),n=Pinia.useAuthStore(),r=Vue.ref(null),i=Vue.computed(()=>n.role==="admin"),o=Vue.computed(()=>(s.locale||"zh-CN")==="zh-CN"),a=Vue.ref(null),l=Vue.ref(!1),c=Vue.ref(null),d=Vue.ref(null),u={id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",nameEn:"Custom",icon:"\u2728",order:99},f=Vue.computed(()=>{if(!a.value)return null;let x=ut[a.value];return x||s.customExpertRoles.find(Y=>Y.id===a.value)||null}),p=Vue.computed(()=>{let x=f.value;return x?`${x.title}\xB7${x.name}`:""}),g=Vue.computed(()=>!a.value||!s.expertRoleDefinitions?null:s.expertRoleDefinitions[a.value]||null),b=Vue.computed(()=>!a.value||ut[a.value]?null:s.customExpertRoles.find(x=>x.id===a.value)||null),h=Vue.ref(new Set([Xc])),A=Vue.computed(()=>e.modelValue),w=Vue.computed(()=>Zc(i.value)),S=Vue.computed(()=>{let x=[...w.value];return x.push({id:"custom",name:o.value?"\u81EA\u5B9A\u4E49":"Custom",icon:"\u2728",order:99}),x}),y=Vue.computed(()=>h.value.has("custom")),m=Vue.computed(()=>new Set(w.value.map(x=>x.id))),v=Vue.computed(()=>Gc().filter(x=>m.value.has(x.teamId)&&h.value.has(x.teamId)));Vue.watch(()=>e.visible,x=>{x&&(s.fetchExpertRoleDefinitions(),s.fetchCustomExpertRoles())});let E=x=>{a.value=x,ut[x]&&s.fetchExpertRoleDefinitions()},V=x=>{c.value=x,l.value=!0},U=()=>{s.fetchCustomExpertRoles()},L=x=>{d.value=x},D=async()=>{if(d.value){try{let x=d.value.id,Y=A.value.filter(oe=>oe.role!==x);Y.length!==A.value.length&&t("update:modelValue",Y),await s.deleteCustomExpertRole(x)}catch{}d.value=null}},M=x=>{if(!(h.value.size===1&&h.value.has(x)))if(h.value=new Set([x]),x==="custom"){let Y=new Set(s.customExpertRoles.map(he=>he.id)),oe=A.value.filter(he=>Y.has(he.role));oe.length!==A.value.length&&t("update:modelValue",oe)}else{let Y=A.value.filter(oe=>{let he=ut[oe.role];return he&&he.group===x});Y.length!==A.value.length&&t("update:modelValue",Y)}},T=(x,Y)=>A.value.some(oe=>oe.role===x&&oe.action===(Y||null)),C=x=>A.value.some(Y=>Y.role===x&&!Y.action),R=x=>A.value.some(Y=>Y.role===x),B=x=>A.value.length>=as&&!R(x),O=(x,Y)=>T(x,Y)?!1:!!(R(x)||A.value.length>=as),j=x=>{if(C(x.id)){t("update:modelValue",A.value.filter(Y=>!(Y.role===x.id&&!Y.action)));return}if(R(x.id)){t("update:modelValue",[...A.value.filter(Y=>Y.role!==x.id),{role:x.id,action:null}]);return}A.value.length>=as||t("update:modelValue",[...A.value,{role:x.id,action:null}])},ne=(x,Y)=>{if(T(x.id,Y.id)){t("update:modelValue",A.value.filter(oe=>!(oe.role===x.id&&oe.action===Y.id)));return}if(R(x.id)){t("update:modelValue",[...A.value.filter(oe=>oe.role!==x.id),{role:x.id,action:Y.id}]);return}A.value.length>=as||t("update:modelValue",[...A.value,{role:x.id,action:Y.id}])};return{store:s,roleListRef:r,enabledTeams:h,selections:A,availableTeams:w,allTeamTabs:S,filteredGroups:v,isZh:o,isCustomTabActive:y,viewingRoleId:a,viewingRoleMeta:f,viewingRoleTitle:p,viewingRoleDef:g,viewingCustomRole:b,viewRole:E,editorOpen:l,editingRole:c,openEditor:V,onEditorSaved:U,deletingRole:d,confirmDeleteRole:L,executeDelete:D,toggleTeam:M,isSelected:T,isRoleOnlySelected:C,hasRoleSelection:R,isRoleDisabled:B,isDisabled:O,toggleRoleOnly:j,toggleAction:ne,toggleCustomRoleOnly:x=>{j(x)},toggleCustomAction:(x,Y)=>{ne(x,Y)},getSelectionLabelFull:x=>{if(ut[x.role])return os(x);let oe=s.customExpertRoles.find(he=>he.id===x.role);if(!oe)return x.role;if(x.action){let he=oe.actions?.find(W=>W.id===x.action);return he?`${oe.name}\xB7${he.name}`:oe.name}return oe.name},removeSelection:x=>{let Y=[...A.value];Y.splice(x,1),t("update:modelValue",Y)},clearAll:()=>{t("update:modelValue",[])},getSelectionLabel:os}}}});var Ii,ja=F(()=>{Nn();Ii={name:"SubAgentPanel",props:{visible:{type:Boolean,default:!1}},emits:["close"],template:`
|
|
4135
4135
|
<div class="subagent-panel" :class="{ open: visible, expanded: store.activeSubagentId }" role="complementary" aria-label="Sub-Agents">
|
|
4136
4136
|
<!-- Expanded Mode: Full message thread for a subagent -->
|
|
4137
4137
|
<template v-if="store.activeSubagentId && activeAgent">
|
|
@@ -4608,7 +4608,7 @@ ${String(e||"").trim()}
|
|
|
4608
4608
|
<slot name="collapsed"></slot>
|
|
4609
4609
|
<slot></slot>
|
|
4610
4610
|
</aside>
|
|
4611
|
-
`}});function Bf(e){let t=typeof e=="number"?e:Date.parse(e||"");return Number.isFinite(t)?t:0}function Wf(e){return[...e].sort((t,s)=>{if(!!t.pinned!=!!s.pinned)return t.pinned?-1:1;let n=Bf(s.metadataUpdatedAt||s.createdAt)-Bf(t.metadataUpdatedAt||t.createdAt);return n!==0?n:String(t.catalogKey||"").localeCompare(String(s.catalogKey||""))})}function
|
|
4611
|
+
`}});function Bf(e){let t=typeof e=="number"?e:Date.parse(e||"");return Number.isFinite(t)?t:0}function Wf(e){return[...e].sort((t,s)=>{if(!!t.pinned!=!!s.pinned)return t.pinned?-1:1;let n=Bf(s.metadataUpdatedAt||s.createdAt)-Bf(t.metadataUpdatedAt||t.createdAt);return n!==0?n:String(t.catalogKey||"").localeCompare(String(s.catalogKey||""))})}function Kt(e){return e?.id||""}function py(e,t,s={}){let i=Math.max(0,Number(s.width)||0),o=Math.max(0,Number(s.height)||0),a=Math.min(Math.max(160,Number(t?.width)||0),Math.max(0,i-16)),l=Math.max(0,Number(t?.height)||0),c=Math.max(0,o-e.bottom-4-8),d=Math.max(0,e.top-4-8),u=c<l&&d>c,f=Math.min(l,u?d:c),p=Math.min(Math.max(8,e.right-a),Math.max(8,i-8-a)),g=u?e.top-4-f:e.bottom+4;return{top:Math.min(Math.max(8,g),Math.max(8,o-8-f)),left:p,width:a,maxHeight:f,placement:u?"above":"below"}}var Pi,Xa=F(()=>{Pi={name:"UnifiedSessionList",emits:["select","create","action","project-action","close-work-center"],props:{sessions:{type:Array,default:()=>[]},projects:{type:Array,default:()=>[]},activeRoute:{type:Object,default:null},isSessionUnread:{type:Function,default:null},processingConversations:{type:Object,default:()=>({})},isYeaftSessionProcessing:{type:Function,default:null},agents:{type:Array,default:()=>[]},workCenterOpen:{type:Boolean,default:!1}},data(){return{collapsedProjects:{},openMenuKey:null,openProjectMenuKey:null,draggedRow:null,dragTargetProjectId:null,projectCreateOpen:!1,projectCreateName:"",projectCreateSubmitting:!1,floatingMenu:null,floatingMenuStyle:{},floatingMenuTrigger:null}},mounted(){document.addEventListener("pointerdown",this.closeMenusFromDocument,!0),document.addEventListener("keydown",this.closeMenusFromKeyboard),window.addEventListener("resize",this.positionFloatingMenu),window.addEventListener("scroll",this.positionFloatingMenu,!0)},beforeUnmount(){document.removeEventListener("pointerdown",this.closeMenusFromDocument,!0),document.removeEventListener("keydown",this.closeMenusFromKeyboard),window.removeEventListener("resize",this.positionFloatingMenu),window.removeEventListener("scroll",this.positionFloatingMenu,!0)},computed:{projectStore(){try{return window.Pinia?.useChatStore?.()||null}catch{return null}},projectRows(){return[...this.projects.length>0?this.projects:this.projectStore?.sessionProjects||[]].sort((t,s)=>(t.sortOrder??Number.MAX_SAFE_INTEGER)-(s.sortOrder??Number.MAX_SAFE_INTEGER))},projectBySessionKey(){let e=new Map;for(let t of this.projectRows){let s=Array.isArray(t.members)?t.members:t.agentId?(t.sessionIds||[]).map(n=>({agentId:t.agentId,sessionId:n})):[];for(let n of s)n?.agentId&&n?.sessionId&&e.set(`${n.agentId}${n.sessionId}`,t)}return e},projectSessionRows(){let e=new Map(this.projectRows.map(t=>[Kt(t),[]]));for(let t of this.sessions){if(t.runtimeProvider!=="yeaft")continue;let s=this.projectBySessionKey.get(`${t.routeRef?.agentId}${t.routeRef?.sessionId}`),n=Kt(s);s&&e.has(n)&&e.get(n).push(t)}return e},rowsByProject(){let e=new Map;for(let[t,s]of this.projectSessionRows)e.set(t,Wf(s.filter(n=>this.isRowOnline(n))));return e},recentRows(){return Wf(this.sessions.filter(e=>{if(!this.isRowOnline(e))return!1;if(e.runtimeProvider==="yeaft"){let t=`${e.routeRef?.agentId}${e.routeRef?.sessionId}`;if(this.projectBySessionKey.has(t))return!1}return!0}))}},methods:{closeMenus(){this.openMenuKey=null,this.openProjectMenuKey=null,this.floatingMenu=null,this.floatingMenuStyle={},this.floatingMenuTrigger=null},closeMenusFromDocument(e){e?.target?.closest?.(".session-menu, .session-dots-btn")||this.closeMenus()},closeMenusFromKeyboard(e){e?.key==="Escape"&&(this.closeMenus(),this.cancelProjectCreate())},toggleProjectMenu(e,t){let s=Kt(e);if(this.openProjectMenuKey===s){this.closeMenus();return}this.openMenuKey=null,this.openProjectMenuKey=s,this.floatingMenu={kind:"project",project:e},this.floatingMenuTrigger=t?.currentTarget||null,this.$nextTick(this.positionFloatingMenu)},toggleSessionMenu(e,t,s){if(this.openMenuKey===e.catalogKey){this.closeMenus();return}this.openProjectMenuKey=null,this.openMenuKey=e.catalogKey,this.floatingMenu={kind:"session",row:e,inProject:t===!0},this.floatingMenuTrigger=s?.currentTarget||null,this.$nextTick(this.positionFloatingMenu)},positionFloatingMenu(){let e=this.floatingMenuTrigger,t=this.$refs.floatingMenu;if(!this.floatingMenu||!e?.isConnected||!t){this.floatingMenu&&e&&!e.isConnected&&this.closeMenus();return}let s=py(e.getBoundingClientRect(),{width:t.scrollWidth||t.offsetWidth||160,height:t.scrollHeight||t.offsetHeight||0},{width:document.documentElement.clientWidth||window.innerWidth,height:document.documentElement.clientHeight||window.innerHeight});this.floatingMenuStyle={top:`${s.top}px`,left:`${s.left}px`,width:`${s.width}px`,maxHeight:`${s.maxHeight}px`}},isActive(e){let t=e?.routeRef,s=this.activeRoute;return!!t&&!!s&&t.runtimeProvider===s.runtimeProvider&&t.agentId===s.agentId&&t.sessionId===s.sessionId},isProcessing(e){return e?.runtimeProvider==="yeaft"?typeof this.isYeaftSessionProcessing=="function"?!!this.isYeaftSessionProcessing(e.routeRef.sessionId,e.routeRef.agentId):!1:!!this.processingConversations?.[e?.routeRef?.sessionId]},isUnread(e){return typeof this.isSessionUnread=="function"?!!this.isSessionUnread(e):!1},isProjectUnread(e){return(this.projectSessionRows.get(Kt(e))||[]).some(s=>this.isUnread(s))},projectKey(e){return Kt(e)},isAgentOnline(e){return!!e&&this.agents.some(t=>t.id===e&&t.online)},isRowOnline(e){return e?.availability!=="online"?!1:this.isAgentOnline(e?.routeRef?.agentId)},canEditProject(e){return e?.id?!e.legacyAgentId||this.isAgentOnline(e.legacyAgentId):!1},canEditRow(e){return!e?.routeRef?.agentId||e.availability!=="online"?!1:this.isAgentOnline(e.routeRef.agentId)},canMoveRowToProject(e,t=null){return this.canEditRow(e)?t?this.canEditProject(t)?!t.legacyAgentId||t.legacyAgentId===e.routeRef.agentId:!1:!0:!1},projectMoveTargets(e){return this.projectRows.filter(t=>this.canMoveRowToProject(e,t))},isProjectCollapsed(e){return this.collapsedProjects[Kt(e)]===!0},toggleProject(e){let t=Kt(e);this.collapsedProjects={...this.collapsedProjects,[t]:!this.collapsedProjects[t]},this.closeMenus()},providerLabel(e){return e.runtimeProvider==="yeaft"?"Yeaft":e.runtimeProvider==="copilot"?"Copilot":"Claude"},agentLabel(e){let t=this.agents.find(s=>s.id===e?.routeRef?.agentId);return e?.agentName||t?.name||e?.routeRef?.agentId||""},createSession(){this.workCenterOpen&&this.$emit("close-work-center"),this.$emit("create")},selectRow(e){this.closeMenus(),this.workCenterOpen&&this.$emit("close-work-center"),this.$emit("select",e)},selectRowFromKeyboard(e,t){t?.target===t?.currentTarget&&(t.preventDefault(),this.selectRow(e))},runAction(e,t){if(this.closeMenus(),!this.canEditRow(t))return;if(e==="rename"){let n=window.prompt(this.$t("yeaft.session.renamePrompt",{name:t.title}),t.title);if(!n?.trim()||n.trim()===t.title)return;this.$emit("action",{action:e,row:t,title:n.trim()});return}let s=e==="delete"?"remove":e;this.$emit("action",{action:s,row:t})},dispatchProjectAction(e){if(e?.action==="move-session"&&!this.canMoveRowToProject(e?.row,e?.project||null))return!1;this.$emit("project-action",e);let t=this.projectStore;if(!t?.mutateProject)return!0;let{action:s,project:n,row:r,name:i,agentId:o}=e,a=o||r?.routeRef?.agentId||null;if(s==="create")return t.mutateProject("create",{name:i},a);let l=n?.legacyProjectId||n?.id;return s==="rename"?t.mutateProject("rename",{projectId:l,name:i},n?.legacyAgentId||a):s==="delete"?t.mutateProject("delete",{projectId:l},n?.legacyAgentId||a):s==="move-session"&&r?.routeRef?.sessionId?t.mutateProject("move_session",{sessionId:r.routeRef.sessionId,projectId:n?.legacyProjectId||n?.id||null},a):!1},createProject(){this.projectCreateSubmitting||(this.projectCreateOpen=!0,this.projectCreateName="",this.$nextTick(()=>this.$refs.projectCreateInput?.focus?.()))},cancelProjectCreate(){this.projectCreateSubmitting||(this.projectCreateOpen=!1,this.projectCreateName="")},async submitProjectCreate(){let e=this.projectCreateName.trim();if(!(!e||this.projectCreateSubmitting)){this.projectCreateSubmitting=!0;try{(await this.dispatchProjectAction({action:"create",name:e}))?.ok!==!1&&(this.projectCreateOpen=!1,this.projectCreateName="")}finally{this.projectCreateSubmitting=!1}}},renameProject(e){if(!this.canEditProject(e))return;let t=window.prompt(this.$t("sidebar.projects.renamePrompt"),e.name);this.closeMenus(),t?.trim()&&t.trim()!==e.name&&this.dispatchProjectAction({action:"rename",project:e,name:t.trim()})},deleteProject(e){this.canEditProject(e)&&(this.closeMenus(),window.confirm(this.$t("sidebar.projects.deleteConfirm",{name:e.name}))&&this.dispatchProjectAction({action:"delete",project:e}))},moveRow(e,t=null){return this.closeMenus(),this.canMoveRowToProject(e,t)?this.dispatchProjectAction({action:"move-session",row:e,project:t}):!1},startDrag(e,t){e.runtimeProvider!=="yeaft"||!this.canEditRow(e)||(this.draggedRow=e,t.dataTransfer.effectAllowed="move",t.dataTransfer.setData("text/plain",e.catalogKey))},dragOverProject(e,t){if(!this.canMoveRowToProject(this.draggedRow,e)){this.dragTargetProjectId=null;return}t.preventDefault(),t.dataTransfer.dropEffect="move",this.dragTargetProjectId=Kt(e)},dropOnProject(e,t){t.preventDefault(),this.canMoveRowToProject(this.draggedRow,e)&&this.moveRow(this.draggedRow,e),this.finishDrag()},dragOverRecents(e){this.draggedRow&&(e.preventDefault(),this.dragTargetProjectId="__recents__")},dropOnRecents(e){e.preventDefault(),this.draggedRow&&this.moveRow(this.draggedRow,null),this.finishDrag()},finishDrag(){this.draggedRow=null,this.dragTargetProjectId=null}},template:`
|
|
4612
4612
|
<nav class="sidebar-navigation" :aria-label="$t('sidebar.surface.sessions')">
|
|
4613
4613
|
<div class="sidebar-primary-actions">
|
|
4614
4614
|
<button type="button" class="sidebar-primary-action" @click="createSession">
|
|
@@ -4621,7 +4621,7 @@ ${String(e||"").trim()}
|
|
|
4621
4621
|
<section class="sidebar-section projects-section">
|
|
4622
4622
|
<div class="sidebar-section-heading">
|
|
4623
4623
|
<span>{{ $t('sidebar.projects.title') }}</span>
|
|
4624
|
-
<button type="button" class="sidebar-tool-button" @click="createProject" :disabled="
|
|
4624
|
+
<button type="button" class="sidebar-tool-button" @click="createProject" :disabled="projectCreateOpen" :title="$t('sidebar.projects.new')" :aria-label="$t('sidebar.projects.new')">
|
|
4625
4625
|
<svg viewBox="0 0 24 24" aria-hidden="true"><path fill="currentColor" d="M11 5h2v6h6v2h-6v6h-2v-6H5v-2h6V5z"/></svg>
|
|
4626
4626
|
</button>
|
|
4627
4627
|
</div>
|
|
@@ -4660,13 +4660,9 @@ ${String(e||"").trim()}
|
|
|
4660
4660
|
<span v-if="isProjectUnread(project)" class="sidebar-session-unread sidebar-project-unread" :aria-label="$t('sidebar.sessions.unread')"></span>
|
|
4661
4661
|
<span class="sidebar-project-count">{{ (rowsByProject.get(projectKey(project)) || []).length }}</span>
|
|
4662
4662
|
</button>
|
|
4663
|
-
<button v-if="canEditProject(project)" type="button" class="session-dots-btn" :class="{ 'menu-open': openProjectMenuKey === projectKey(project) }" @click.stop="
|
|
4663
|
+
<button v-if="canEditProject(project)" type="button" class="session-dots-btn" :class="{ 'menu-open': openProjectMenuKey === projectKey(project) }" @click.stop="toggleProjectMenu(project, $event)" :aria-label="$t('sidebar.projects.menu')">
|
|
4664
4664
|
<svg viewBox="0 0 24 24"><path fill="currentColor" d="M6 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/></svg>
|
|
4665
4665
|
</button>
|
|
4666
|
-
<div v-if="openProjectMenuKey === projectKey(project)" class="session-menu">
|
|
4667
|
-
<button class="session-menu-item" @click.stop="renameProject(project)">{{ $t('sidebar.projects.rename') }}</button>
|
|
4668
|
-
<button class="session-menu-item danger" @click.stop="deleteProject(project)">{{ $t('sidebar.projects.delete') }}</button>
|
|
4669
|
-
</div>
|
|
4670
4666
|
</div>
|
|
4671
4667
|
<div v-if="!isProjectCollapsed(project)" class="sidebar-project-sessions">
|
|
4672
4668
|
<div
|
|
@@ -4692,19 +4688,7 @@ ${String(e||"").trim()}
|
|
|
4692
4688
|
</span>
|
|
4693
4689
|
</span>
|
|
4694
4690
|
<span v-if="canEditRow(row)" class="session-actions">
|
|
4695
|
-
<button type="button" class="session-dots-btn" :class="{ 'menu-open': openMenuKey === row.catalogKey }" @click.stop="
|
|
4696
|
-
<div v-if="openMenuKey === row.catalogKey" class="session-menu">
|
|
4697
|
-
<button class="session-menu-item" @click.stop="runAction('pin', row)">{{ row.pinned ? $t('chat.sidebar.unpin') : $t('chat.sidebar.pin') }}</button>
|
|
4698
|
-
<button class="session-menu-item" @click.stop="runAction('rename', row)">{{ $t('chat.sidebar.renameConv') }}</button>
|
|
4699
|
-
<button class="session-menu-item" @click.stop="runAction('settings', row)">{{ $t('yeaft.session.openSettings') }}</button>
|
|
4700
|
-
<button class="session-menu-item" @click.stop="moveRow(row, null)">{{ $t('sidebar.projects.remove') }}</button>
|
|
4701
|
-
<button class="session-menu-item danger" @click.stop="runAction('delete', row)">{{ $t('common.delete') }}</button>
|
|
4702
|
-
<div class="sidebar-session-menu-divider"></div>
|
|
4703
|
-
<div class="sidebar-session-menu-info">
|
|
4704
|
-
<span><span>{{ $t('sidebar.sessions.agent') }}</span><strong :title="agentLabel(row)">{{ agentLabel(row) }}</strong></span>
|
|
4705
|
-
<span><span>{{ $t('sidebar.sessions.provider') }}</span><strong>{{ providerLabel(row) }}</strong></span>
|
|
4706
|
-
</div>
|
|
4707
|
-
</div>
|
|
4691
|
+
<button type="button" class="session-dots-btn" :class="{ 'menu-open': openMenuKey === row.catalogKey }" @click.stop="toggleSessionMenu(row, true, $event)" :aria-label="$t('sidebar.sessions.menu')"><svg viewBox="0 0 24 24"><path fill="currentColor" d="M6 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/></svg></button>
|
|
4708
4692
|
</span>
|
|
4709
4693
|
</div>
|
|
4710
4694
|
<div v-if="(rowsByProject.get(projectKey(project)) || []).length === 0" class="sidebar-section-empty">{{ $t('sidebar.projects.noSessions') }}</div>
|
|
@@ -4737,26 +4721,37 @@ ${String(e||"").trim()}
|
|
|
4737
4721
|
</span>
|
|
4738
4722
|
</span>
|
|
4739
4723
|
<span v-if="canEditRow(row)" class="session-actions">
|
|
4740
|
-
<button type="button" class="session-dots-btn" :class="{ 'menu-open': openMenuKey === row.catalogKey }" @click.stop="
|
|
4741
|
-
<div v-if="openMenuKey === row.catalogKey" class="session-menu">
|
|
4742
|
-
<button class="session-menu-item" @click.stop="runAction('pin', row)">{{ row.pinned ? $t('chat.sidebar.unpin') : $t('chat.sidebar.pin') }}</button>
|
|
4743
|
-
<button class="session-menu-item" @click.stop="runAction('rename', row)">{{ $t('chat.sidebar.renameConv') }}</button>
|
|
4744
|
-
<template v-if="row.runtimeProvider === 'yeaft'">
|
|
4745
|
-
<button class="session-menu-item" @click.stop="runAction('settings', row)">{{ $t('yeaft.session.openSettings') }}</button>
|
|
4746
|
-
<button v-for="project in projectRows.filter(item => item.agentId === row.routeRef.agentId)" :key="project.id" class="session-menu-item" @click.stop="moveRow(row, project)">{{ $t('sidebar.projects.moveTo', { name: project.name }) }}</button>
|
|
4747
|
-
</template>
|
|
4748
|
-
<button class="session-menu-item danger" @click.stop="runAction('delete', row)">{{ $t('common.delete') }}</button>
|
|
4749
|
-
<div class="sidebar-session-menu-divider"></div>
|
|
4750
|
-
<div class="sidebar-session-menu-info">
|
|
4751
|
-
<span><span>{{ $t('sidebar.sessions.agent') }}</span><strong :title="agentLabel(row)">{{ agentLabel(row) }}</strong></span>
|
|
4752
|
-
<span><span>{{ $t('sidebar.sessions.provider') }}</span><strong>{{ providerLabel(row) }}</strong></span>
|
|
4753
|
-
</div>
|
|
4754
|
-
</div>
|
|
4724
|
+
<button type="button" class="session-dots-btn" :class="{ 'menu-open': openMenuKey === row.catalogKey }" @click.stop="toggleSessionMenu(row, false, $event)" :aria-label="$t('sidebar.sessions.menu')"><svg viewBox="0 0 24 24"><path fill="currentColor" d="M6 10a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm6 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/></svg></button>
|
|
4755
4725
|
</span>
|
|
4756
4726
|
</div>
|
|
4757
4727
|
<div v-if="recentRows.length === 0" class="sidebar-section-empty">{{ $t('sidebar.recents.empty') }}</div>
|
|
4758
4728
|
</section>
|
|
4759
4729
|
</div>
|
|
4730
|
+
|
|
4731
|
+
<Teleport to="body">
|
|
4732
|
+
<div v-if="floatingMenu" ref="floatingMenu" class="session-menu session-menu-floating" :style="floatingMenuStyle">
|
|
4733
|
+
<template v-if="floatingMenu.kind === 'project'">
|
|
4734
|
+
<button class="session-menu-item" @click.stop="renameProject(floatingMenu.project)">{{ $t('sidebar.projects.rename') }}</button>
|
|
4735
|
+
<button class="session-menu-item danger" @click.stop="deleteProject(floatingMenu.project)">{{ $t('sidebar.projects.delete') }}</button>
|
|
4736
|
+
</template>
|
|
4737
|
+
<template v-else>
|
|
4738
|
+
<button class="session-menu-item" @click.stop="runAction('pin', floatingMenu.row)">{{ floatingMenu.row.pinned ? $t('chat.sidebar.unpin') : $t('chat.sidebar.pin') }}</button>
|
|
4739
|
+
<button class="session-menu-item" @click.stop="runAction('rename', floatingMenu.row)">{{ $t('chat.sidebar.renameConv') }}</button>
|
|
4740
|
+
<template v-if="floatingMenu.row.runtimeProvider === 'yeaft'">
|
|
4741
|
+
<button class="session-menu-item" @click.stop="runAction('settings', floatingMenu.row)">{{ $t('yeaft.session.openSettings') }}</button>
|
|
4742
|
+
<button v-if="floatingMenu.inProject" class="session-menu-item" @click.stop="moveRow(floatingMenu.row, null)">{{ $t('sidebar.projects.remove') }}</button>
|
|
4743
|
+
<template v-else>
|
|
4744
|
+
<button v-for="project in projectMoveTargets(floatingMenu.row)" :key="project.id" class="session-menu-item" @click.stop="moveRow(floatingMenu.row, project)">{{ $t('sidebar.projects.moveTo', { name: project.name }) }}</button>
|
|
4745
|
+
</template>
|
|
4746
|
+
</template>
|
|
4747
|
+
<button class="session-menu-item danger" @click.stop="runAction('delete', floatingMenu.row)">{{ $t('common.delete') }}</button>
|
|
4748
|
+
<div class="sidebar-session-menu-info">
|
|
4749
|
+
<strong :title="agentLabel(floatingMenu.row)">{{ agentLabel(floatingMenu.row) }}</strong>
|
|
4750
|
+
<strong>{{ providerLabel(floatingMenu.row) }}</strong>
|
|
4751
|
+
</div>
|
|
4752
|
+
</template>
|
|
4753
|
+
</div>
|
|
4754
|
+
</Teleport>
|
|
4760
4755
|
</nav>
|
|
4761
4756
|
`}});var Uf,jf=F(()=>{Ws();Uf={name:"VpAvatar",props:{vpId:{type:String,required:!0},size:{type:Number,default:20},status:{type:String,default:null},typing:{type:Boolean,default:!1},ariaLabel:{type:String,default:""}},template:`
|
|
4762
4757
|
<span
|
|
@@ -4785,7 +4780,7 @@ ${String(e||"").trim()}
|
|
|
4785
4780
|
<span class="vp-avatar-typing-dot"></span>
|
|
4786
4781
|
</span>
|
|
4787
4782
|
</span>
|
|
4788
|
-
`,setup(e){let t=yt(),s=Vue.computed(()=>t.vpInitial(e.vpId)),n=Vue.computed(()=>t.vpLabel(e.vpId)),r=Vue.computed(()=>{let d=t.vpAvatarMotif;return typeof d=="function"?d(e.vpId):{key:"rat",glyph:"R",background:"linear-gradient(135deg, #174EA6 0%, #0B2F6B 100%)",foreground:"#FFFFFF"}}),i=Vue.computed(()=>{let d=t.vpColor;return typeof d=="function"?d(e.vpId):r.value.background}),o=Vue.computed(()=>r.value.key),a=Vue.computed(()=>r.value.glyph),l=Vue.computed(()=>r.value.foreground),c=Vue.computed(()=>({width:e.size+"px",height:e.size+"px",background:i.value,color:l.value,fontSize:Math.max(13,Math.round(e.size*.58))+"px"}));return{initial:s,displayName:n,avatarStyle:c,motifKey:o,motifGlyph:a}}}});function Zn(e){if(!e)return"";let t=String(e).split(/[/\\]/);return t[t.length-1]||t[t.length-2]||e}function Ri(e,t){if(!e)return"";let s=new Date(e);if(isNaN(s.getTime()))return"";let r=Math.floor((new Date-s)/(1e3*60*60*24)),i=typeof t=="function"?t:((o,a)=>a&&a.count!=null?`${a.count}d`:o);return r===0?i("chat.time.today")+" "+s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):r===1?i("chat.time.yesterday")+" "+s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):r<7?i("chat.time.daysAgo",{count:r}):s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Za=F(()=>{});function
|
|
4783
|
+
`,setup(e){let t=yt(),s=Vue.computed(()=>t.vpInitial(e.vpId)),n=Vue.computed(()=>t.vpLabel(e.vpId)),r=Vue.computed(()=>{let d=t.vpAvatarMotif;return typeof d=="function"?d(e.vpId):{key:"rat",glyph:"R",background:"linear-gradient(135deg, #174EA6 0%, #0B2F6B 100%)",foreground:"#FFFFFF"}}),i=Vue.computed(()=>{let d=t.vpColor;return typeof d=="function"?d(e.vpId):r.value.background}),o=Vue.computed(()=>r.value.key),a=Vue.computed(()=>r.value.glyph),l=Vue.computed(()=>r.value.foreground),c=Vue.computed(()=>({width:e.size+"px",height:e.size+"px",background:i.value,color:l.value,fontSize:Math.max(13,Math.round(e.size*.58))+"px"}));return{initial:s,displayName:n,avatarStyle:c,motifKey:o,motifGlyph:a}}}});function Zn(e){if(!e)return"";let t=String(e).split(/[/\\]/);return t[t.length-1]||t[t.length-2]||e}function Ri(e,t){if(!e)return"";let s=new Date(e);if(isNaN(s.getTime()))return"";let r=Math.floor((new Date-s)/(1e3*60*60*24)),i=typeof t=="function"?t:((o,a)=>a&&a.count!=null?`${a.count}d`:o);return r===0?i("chat.time.today")+" "+s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):r===1?i("chat.time.yesterday")+" "+s.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):r<7?i("chat.time.daysAgo",{count:r}):s.toLocaleDateString(void 0,{month:"short",day:"numeric"})}var Za=F(()=>{});function fy(){return zf+=1,`folder-picker-${Date.now()}-${zf}`}var Ja,zf,el,gy,Kf,tl=F(()=>{Ja=()=>({folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",_folderPickerTimer:null,_folderPickerRequestId:null,_folderPickerRequestAgentId:null}),zf=0;el={openFolderPicker(){if(!this.folderPickerAgentId||!this.chat||typeof this.chat.sendWsMessage!="function")return;this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let t=typeof this.folderPickerInitialDir=="function"?this.folderPickerInitialDir()||"":this.defaultWorkDir||"";this.folderPickerPath=t,this.folderPickerEntries=[],this.requestFolderPickerDir(t)},invalidateFolderPickerRequest(){this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},closeFolderPicker(){this.folderPickerOpen=!1,this.invalidateFolderPickerRequest()},requestFolderPickerDir(e){let t=this.folderPickerAgentId;if(!t||!this.chat||typeof this.chat.sendWsMessage!="function")return;let s=fy();this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t,this.chat.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",requestId:s,agentId:t,dirPath:e,workDir:this.defaultWorkDir||""}),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&this._folderPickerRequestId===s&&this.folderPickerAgentId===t&&this.requestFolderPickerDir(e)},5e3)},loadFolderPickerDir(e){this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[],this.requestFolderPickerDir(e)},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(this.folderPickerPath);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:n=/^[A-Z]:$/.test(e.name)?e.name+"\\":"/"+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}typeof this.folderPickerSetWorkDir=="function"&&this.folderPickerSetWorkDir(e),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.folderPickerAgentId!==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))}},gy={data(){return Ja()},methods:{...el},mounted(){window.addEventListener("workbench-message",this.handleFolderPickerMessage)},beforeUnmount(){window.removeEventListener("workbench-message",this.handleFolderPickerMessage),this.invalidateFolderPickerRequest()}},Kf=gy});function my(e,t,s,n=0){let r=Math.max(t.top,s.top),i=Math.min(t.bottom,s.bottom),o=Math.max(0,e.top-r-Gf),a=Math.max(0,i-e.bottom-Gf),l=Math.max(0,Number(n)||0),c="down";return(a<l&&o>=l||a<l&&o>a)&&(c="up"),{placement:c,availableHeight:Math.floor(c==="up"?o:a)}}var Yf,Gf,en,_i=F(()=>{jf();Za();Kn();Rn();tl();Yf="omni",Gf=4;en={name:"SessionCreateModal",components:{VpAvatar:Uf},props:{initialProvider:{type:String,default:"yeaft"}},emits:["close","created"],template:`
|
|
4789
4784
|
<Teleport to="body">
|
|
4790
4785
|
<div class="modal-overlay" @click.self="onOverlayClick" role="dialog" aria-modal="true" :aria-label="$t('yeaft.session.create.title')">
|
|
4791
4786
|
<div class="modal resume-modal yeaft-session-create-modal">
|
|
@@ -5082,7 +5077,7 @@ ${String(e||"").trim()}
|
|
|
5082
5077
|
</div>
|
|
5083
5078
|
</div>
|
|
5084
5079
|
</Teleport>
|
|
5085
|
-
`,data(){return{form:{provider:["yeaft","copilot","claude-code"].includes(this.initialProvider)?this.initialProvider:"yeaft",name:"",vpIds:[],defaultVpId:null,workDir:"",agentId:null},busy:!1,submitError:"",...Ja(),vpPickerTouched:!1,vpRosterOpen:!1,vpRosterPlacement:"down",vpRosterAvailableHeight:null,scannedSessions:[],restoreScanning:!1,restoring:null,restoreError:"",vpSnapshotTimer:null}},computed:{chat(){try{if(typeof window<"u"&&window.Pinia?.useChatStore)return window.Pinia.useChatStore()}catch{}return null},vpStore(){try{if(typeof window<"u"&&window.Pinia?.useVpStore)return window.Pinia.useVpStore()}catch{}return null},sessionsStore(){try{if(typeof window<"u"&&window.Pinia?.useSessionsStore)return window.Pinia.useSessionsStore()}catch{}return null},isYeaftProvider(){return this.form.provider==="yeaft"},vpLibraryReady(){let e=this.vpStore;return!!(e&&e.snapshotStatus==="ready"&&e.snapshotAgentId===this.form.agentId&&e.lastVpSnapshotAgentId===this.form.agentId)},vpList(){return this.vpLibraryReady?this.vpStore?.vpList||[]:[]},vpDomainSections(){return ms(this.vpList)},vpListSignature(){return(this.vpList||[]).map(e=>e&&e.vpId).filter(Boolean).join(",")},vpLibraryEmpty(){let e=this.vpStore;return!e||!this.vpLibraryReady?!1:e.emptyLibrary===!0?!0:!!(e.lastSnapshotAt&&e.lastSnapshotAt>0&&(e.vpOrder?.length||0)===0)},vpLibraryError(){let e=this.vpStore;return!e||e.snapshotStatus!=="error"?!1:!e.snapshotAgentId||e.snapshotAgentId===this.form.agentId},agentOptions(){let e=this.chat;return!e||!Array.isArray(e.agents)?[]:e.agents.map(t=>({id:t.id,name:t.name,online:!!t.online,workDir:t.workDir||""}))},agentSignature(){return this.agentOptions.map(e=>`${e.id}:${e.online?1:0}`).join(",")},folderPickerAgentId(){return this.form.agentId||this.chat?.currentAgent||""},defaultWorkDir(){return this.agentOptions.find(t=>t.id===this.form.agentId)?.workDir||this.chat?.currentAgentInfo?.workDir||""},workDirPlaceholder(){return this.defaultWorkDir||this.$t("modal.newConv.inputOrSelect")},allSessions(){return this.sessionsStore?.sessionList||[]},agentSessions(){let e=this.form.agentId||null;return e?this.allSessions.filter(t=>{let s=t&&t.agentId;return!s||s===e}):this.allSessions},folderAggregates(){let e=new Map;for(let t of this.agentSessions){let s=t&&typeof t.workDir=="string"?t.workDir.trim():"";if(!s)continue;let n=e.get(s)||{path:s,count:0};n.count+=1,e.set(s,n)}return Array.from(e.values()).sort((t,s)=>t.path.localeCompare(s.path))},sessionsInDir(){let e=this.form.agentId||null;return(Array.isArray(this.scannedSessions)?this.scannedSessions:[]).filter(s=>s&&s.id).map(s=>{let n=s.agentId||e,r=dt(n,s.id),i=!!(r&&this.sessionsStore?.sessions?.[r]);return{...s,...n?{agentId:n}:{},inSidebar:i}})},chatFolderRows(){return(this.chat?.folders||[]).map(e=>({path:e.path||e.name||"",count:Number(e.sessionCount)||0})).filter(e=>e.path)},createFolderRows(){return this.isYeaftProvider?this.folderAggregates:this.chatFolderRows},createSessionRows(){return this.isYeaftProvider?this.sessionsInDir:(this.chat?.historySessions||[]).map(e=>({...e,id:e.sessionId,name:e.title,createdAt:e.lastModified}))},canSubmit(){if(this.isYeaftProvider&&(!this.vpLibraryReady||this.form.vpIds.length===0)||!this.form.agentId)return!1;let e=this.agentOptions.find(t=>t.id===this.form.agentId);return!!(e&&e.online)},vpRosterSummary(){let e=this.form.vpIds||[];return e.length===0?this.$t("yeaft.session.create.vpNone"):e.length<=3?e.map(t=>this.vpLabelFor(t)).join(this.$t("common.comma")):this.$t("yeaft.session.create.vpCount",{n:e.length})},vpRosterPopupStyle(){return Number.isFinite(this.vpRosterAvailableHeight)?{"--vp-roster-available-height":`${this.vpRosterAvailableHeight}px`}:{}}},mounted(){window.addEventListener("keydown",this.onEsc),window.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("scroll",this.scheduleVpRosterLayout),window.addEventListener("workbench-message",this.handleFolderPickerMessage),document.addEventListener("click",this.handleOutsideRosterClick,!0),this.seedAgentDefault(),this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()},watch:{vpListSignature(){this.applyDefaultSelection(),this.scheduleVpRosterLayout()},agentSignature(){this.seedAgentDefault(),this.scheduleVpRosterLayout()},"form.provider"(e,t){e!==t&&(this.form.workDir="",this.scannedSessions=[],this.restoreError="",e==="yeaft"?(this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()):this.form.agentId&&this.chat?.listFoldersForAgent?.(this.form.agentId,e))},"form.agentId"(e,t){e!==t&&(this.isYeaftProvider&&this.subscribeVpsFor(e),this.form.vpIds=[],this.form.defaultVpId=null,this.vpPickerTouched=!1,this.isYeaftProvider&&this.applyDefaultSelection(),this.scannedSessions=[],this.restoreError="",!this.isYeaftProvider&&e&&this.chat?.listFoldersForAgent?.(e,this.form.provider),(this.form.workDir||"").trim()&&this.loadProviderSessions())},"form.workDir"(e,t){e===t||(this.restoreError="",this.scannedSessions=[],!(e||"").trim())||this.loadProviderSessions()}},beforeUnmount(){window.removeEventListener("keydown",this.onEsc),window.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("scroll",this.scheduleVpRosterLayout),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),document.removeEventListener("click",this.handleOutsideRosterClick,!0),this._vpRosterLayoutFrame&&cancelAnimationFrame(this._vpRosterLayoutFrame),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer)},methods:{toggleVpRoster(){if(this.vpRosterOpen){this.closeVpRoster();return}this.vpRosterPlacement="down",this.vpRosterAvailableHeight=null,this.vpRosterOpen=!0,this.$nextTick(this.scheduleVpRosterLayout)},closeVpRoster(){this.vpRosterOpen=!1,this.vpRosterAvailableHeight=null},scheduleVpRosterLayout(){!this.vpRosterOpen||this._vpRosterLayoutFrame||(this._vpRosterLayoutFrame=requestAnimationFrame(()=>{this._vpRosterLayoutFrame=null,this.updateVpRosterLayout()}))},updateVpRosterLayout(){if(!this.vpRosterOpen)return;let e=this.$refs.vpRosterTrigger,t=this.$refs.vpRosterPopup,s=e?.closest?.(".resume-modal");if(!e||!t||!s)return;let n=t.style.maxHeight;t.style.maxHeight="none";let r=t.scrollHeight;t.style.maxHeight=n;let i=window.visualViewport,o=i?i.offsetTop:0,a=i?i.height:window.innerHeight,l={top:o,bottom:o+a},c=s.getBoundingClientRect(),d=gy(e.getBoundingClientRect(),c,l,r);this.vpRosterPlacement=d.placement,this.vpRosterAvailableHeight=d.availableHeight},seedAgentDefault(){try{let e=this.agentOptions;if(!Array.isArray(e)||e.length===0||e.find(i=>i.id===this.form.agentId&&i.online))return;let s=this.chat,n=s&&s.currentAgent||null,r=e.find(i=>i.id===n&&i.online)||e.find(i=>i.online)||null;r&&(this.form.agentId=r.id)}catch{}},subscribeVpsFor(e,{force:t=!1}={}){let s=this.chat,n=e||s?.currentAgent||null,r=this.vpStore;if(!s||typeof s.sendWsMessage!="function"||!n){let l=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,l),r?.failSnapshot?.(n,l,"No online Agent is available."),!1}if(!t&&r?.snapshotStatus==="ready"&&r.snapshotAgentId===n&&r.lastVpSnapshotAgentId===n)return this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=null,!0;let o=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,o),s.sendWsMessage({type:"yeaft_vp_subscribe",agentId:n,requestId:o})===!1?(r?.failSnapshot?.(n,o,"WebSocket is not connected."),!1):(this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=setTimeout(()=>{this.vpSnapshotTimer=null,r?.snapshotStatus==="loading"&&r.snapshotRequestId===o&&r.failSnapshot(n,o,"VP library request timed out.")},1e4),!0)},retryVpSnapshot(){this.subscribeVpsFor(this.form.agentId,{force:!0})},loadProviderSessions(){if(this.isYeaftProvider)return this.loadRestoreCandidates();let e=(this.form.workDir||"").trim();!e||!this.form.agentId||this.chat?.listHistorySessionsForAgent?.(this.form.agentId,e,this.form.provider)},async loadRestoreCandidates(){if(this.restoreScanning)return;let e=(this.form.workDir||"").trim();if(!e){this.scannedSessions=[];return}let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"no agent selected"});return}this.restoreScanning=!0,this.restoreError="";try{let n=await t.sessionCrudRequest("scan_workdir",{workDir:e},{agentId:s});if(n&&n.ok){let r=Array.isArray(n.sessions)?n.sessions:Array.isArray(n.groups)?n.groups:[];this.scannedSessions=r}else{this.scannedSessions=[];let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:r})}}catch(n){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:n?.message||String(n)})}finally{this.restoreScanning=!1}},async onRestoreClick(e){if(!e||!e.id||this.restoring)return;let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"no agent selected"});return}this.restoring=e.id,this.restoreError="";try{let n=await t.sessionCrudRequest("restore",{sessionId:e.id,workDir:(this.form.workDir||"").trim()},{agentId:s});if(n&&n.ok){let i=n.session||n.group||e,o=i?.agentId||e.agentId||s;o&&t.currentAgent!==o&&typeof t.selectAgent=="function"&&t.selectAgent(o),this.sessionsStore&&this.sessionsStore.setActive(i.id||e.id,o),typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(i.id||e.id,{agentId:o,force:!0}),this.$emit("created",i),this.$emit("close");return}let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:r})}catch(n){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:n?.message||String(n)})}finally{this.restoring=null}},applyDefaultSelection(){if(this.vpPickerTouched)return;let e=this.vpList||[];if(e.length===0)return;let t=e.map(o=>o&&o.vpId).filter(Boolean);if(t.length===0)return;let s=Array.isArray(this.form.vpIds)?this.form.vpIds:[],n=s.filter(o=>t.includes(o)),r=this.form.defaultVpId&&n.includes(this.form.defaultVpId);if(n.length>0&&r){n.length!==s.length&&(this.form.vpIds=n);return}let i=t.includes(Yf)?Yf:n[0]||t[0];this.form.vpIds=[i],this.form.defaultVpId=i},toggleVp(e,t){this.vpPickerTouched=!0,t?(this.form.vpIds.includes(e)||this.form.vpIds.push(e),this.form.defaultVpId||(this.form.defaultVpId=e)):(this.form.vpIds=this.form.vpIds.filter(s=>s!==e),this.form.defaultVpId&&!this.form.vpIds.includes(this.form.defaultVpId)&&(this.form.defaultVpId=this.form.vpIds[0]||null))},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},vpTextColorFor(e){let t=this.vpStore?.vpTextColor;return typeof t=="function"?t(e):"var(--text-primary)"},selectFolder(e){this.form.workDir=e},selectSession(e){if(!(!e||!e.id)){if(!this.isYeaftProvider){let t=e.workDir||(this.form.workDir||"").trim()||this.defaultWorkDir;this.chat?.selectAgent?.(this.form.agentId),this.chat._pendingSessionTitle=e.name||e.title||null,this.chat?.resumeConversation?.(e.id,t,this.form.agentId,this.chatProviderOptions()),this.$emit("close");return}e.inSidebar?this.resumeExisting(e):this.onRestoreClick(e)}},chatProviderOptions(){let e={provider:this.form.provider};return this.form.provider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeExisting(e){if(!e||!e.id)return;let t=this.chat,s=e.agentId||this.form.agentId||null;s&&t&&t.currentAgent!==s&&typeof t.selectAgent=="function"&&t.selectAgent(s),this.sessionsStore&&this.sessionsStore.setActive(e.id,s),t&&typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(e.id,{agentId:s,force:!0}),this.$emit("close")},handleOutsideRosterClick(e){if(!this.vpRosterOpen)return;let t=this.$refs.vpRosterRoot;t&&(t.contains(e.target)||this.closeVpRoster())},getLastPathSegment(e){return Zn(e)},formatDate(e){return Ri(e,this.$t.bind(this))},onEsc(e){if(e.key==="Escape"&&!this.folderPickerOpen){if(this.vpRosterOpen){this.closeVpRoster();return}this.busy||this.requestClose()}},onOverlayClick(){this.busy||this.requestClose()},requestClose(){this.$emit("close")},folderPickerInitialDir(){return this.form.workDir||this.defaultWorkDir||""},folderPickerSetWorkDir(e){this.form.workDir=e},...el,async onSubmit(){if(!(this.busy||!this.canSubmit)){this.submitError="",this.busy=!0;try{if(!this.chat){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}if(!this.isYeaftProvider){let d=this.form.workDir.trim()||this.defaultWorkDir;this.chat.selectAgent?.(this.form.agentId),this.chat.createConversation?.(d,this.form.agentId,null,this.chatProviderOptions()),this.$emit("created",{provider:this.form.provider,workDir:d}),this.$emit("close");return}if(typeof this.chat.createYeaftSession!="function"){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}let e=new Set((this.vpList||[]).map(d=>d&&d.vpId).filter(Boolean)),t=this.form.vpIds.filter(d=>e.has(d));if(t.length===0){this.submitError=this.$t("yeaft.session.error.unknown",{message:"no valid VP selected"});return}let s=this.form.defaultVpId&&t.includes(this.form.defaultVpId)?this.form.defaultVpId:t[0],r=this.form.name.trim()||Zn(this.form.workDir.trim())||this.$t("yeaft.session.create.untitled"),i=await this.chat.createYeaftSession({displayName:r,vpIds:t,defaultVpId:s,workDir:this.form.workDir.trim(),agentId:this.form.agentId||null});if(i&&i.ok){let d=this.chat,u=i.session||i.group||null,f=u&&u.id,p=u?.agentId||this.form.agentId||null;f&&(p&&d&&d.currentAgent!==p&&typeof d.selectAgent=="function"&&d.selectAgent(p),this.sessionsStore&&this.sessionsStore.setActive(f,p),d&&typeof d.setActiveSessionFilter=="function"&&d.setActiveSessionFilter(f,{agentId:p,force:!0})),this.$emit("created",u),this.$emit("close");return}let o=i?.error?.code||"unknown",a=i?.error?.message||"",l=`yeaft.session.error.${o}`,c=this.$t(l,{message:a});this.submitError=c===l?this.$t("yeaft.session.error.unknown",{message:a}):c}catch(e){this.submitError=this.$t("yeaft.session.error.unknown",{message:e?.message||String(e)})}finally{this.busy=!1}}}}}});function bs(e){return!e?.runId||!e?.id?"":`${e.runId}:${e.id}`}function Qf(e,t){let s=bs(e);return s?`${s}:${t?.id||t?.loopNumber||""}`:""}var sl=F(()=>{});var Xf,Zf=F(()=>{Nn();sl();Xf={name:"WorkCenterActionDetail",props:{action:{type:Object,default:null},selected:{type:Object,default:null},messages:{type:Array,default:()=>[]},messagesNextCursor:{type:[String,Number],default:null},messagesLoading:{type:Boolean,default:!1},messagesError:{type:String,default:""},requests:{type:Array,default:()=>[]},requestDetails:{type:Object,default:()=>({})},requestDetailsLoading:{type:Object,default:()=>({})},requestDetailsError:{type:Object,default:()=>({})},requestsLoading:{type:Boolean,default:!1},requestsError:{type:String,default:""},previewingAttachmentId:{type:String,default:null},attachmentError:{type:String,default:""}},emits:["back","target-action","load-earlier-messages","select-request","refresh-requests","open-run","open-attachment"],data(){return{activeView:"conversation",conversationScrollTop:0,expandedRequestKey:null,requestSelectionTouched:!1}},computed:{executorName(){return this.action?.assignedVp?.name||this.action?.assignedVp?.id||this.action?.requiredRole||this.tr("workCenter.actionExecutorPending","Executor pending")},canTargetAction(){return!this.action||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(this.action.status)&&this.action.admissionStatus!=="blocked"},hasMessages(){return this.messages.length>0},hasActionBrief(){return!!this.action?.brief?.approach||!!this.action?.brief?.expectedOutcome||!!this.action?.dependsOnStageIds?.length||!!this.action?.canonicalResult?.summary},waitingQuestion(){return this.action?.status!=="waiting"?"":String(this.action?.canonicalResult?.waitingReason||"").trim()},currentGenerationRequests(){let e=Math.max(1,Number(this.action?.generation)||1);return this.requests.filter(t=>Math.max(1,Number(t?.generation)||1)===e).slice().sort((t,s)=>(Number(s?.attempt)||0)-(Number(t?.attempt)||0)||(Number(s?.openedAt)||0)-(Number(t?.openedAt)||0)||String(s?.id||"").localeCompare(String(t?.id||"")))}},watch:{"action.id"(){this.resetActionView()},"action.generation"(e,t){let s=Math.max(1,Number(e)||1),n=Math.max(1,Number(t)||1);s!==n&&this.resetActionView()},messages:{deep:!0,handler(){this.$nextTick(()=>Ye(this.$el))}},requests(){this.activeView!=="execution"||this.requestSelectionTouched||this.$nextTick(()=>this.syncLatestRequest())}},mounted(){this.$nextTick(()=>Ye(this.$el))},methods:{tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},messageSpeaker(e){return e?.role==="user"?this.tr("workCenter.you","You"):e?.speaker?.name||e?.speaker?.id||this.executorName},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},formatDuration(e){let t=Math.max(0,Number(e)||0);return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},messageHtml(e){return ii(String(e||""))},json(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},requestKey(e){return bs(e)},requestLoopKey(e,t){return Qf(e,t)},requestDetail(e){let t=this.requestDetails[this.requestKey(e)]||null;return t?.request||t},resetActionView(){this.activeView="conversation",this.conversationScrollTop=0,this.expandedRequestKey=null,this.requestSelectionTouched=!1,this.$nextTick(()=>{this.$refs.conversationPanel&&(this.$refs.conversationPanel.scrollTop=0),Ye(this.$el)})},tabId(e){return`work-center-action-${e}-tab`},panelId(e){return`work-center-action-${e}-panel`},onTabKeydown(e,t){let s=["conversation","execution"],n=s.indexOf(t);if(n<0)return;let r;if(e.key==="ArrowRight")r=(n+1)%s.length;else if(e.key==="ArrowLeft")r=(n-1+s.length)%s.length;else if(e.key==="Home")r=0;else if(e.key==="End")r=s.length-1;else return;e.preventDefault();let i=s[r];this.setActiveView(i),this.$nextTick(()=>this.$refs[`${i}Tab`]?.focus())},async openRun(e){let t=this.action?.id,s=this.action?.generation,n=await new Promise(r=>this.$emit("open-run",e,r));!n||this.action?.id!==t||this.action?.generation!==s||(this.activeView="execution",this.requestSelectionTouched=!0,this.expandedRequestKey=this.requestKey(n),await this.$nextTick(),this.$refs.requestsPanel?.scrollIntoView?.({behavior:"smooth",block:"start"}))},setActiveView(e){e!==this.activeView&&(this.activeView==="conversation"&&(this.conversationScrollTop=this.$refs.conversationPanel?.scrollTop||0),this.activeView=e,e==="execution"&&(this.refreshRequests(),this.$nextTick(()=>this.syncLatestRequest())),this.$nextTick(()=>{e==="conversation"&&this.$refs.conversationPanel&&(this.$refs.conversationPanel.scrollTop=this.conversationScrollTop),Ye(this.$el)}))},async toggleRequest(e){let t=this.requestKey(e);if(this.requestSelectionTouched=!0,this.expandedRequestKey===t){this.expandedRequestKey=null;return}this.expandedRequestKey=t,this.requestDetail(e)||this.$emit("select-request",e)},syncLatestRequest(){if(this.requestSelectionTouched)return;let e=this.currentGenerationRequests[0];if(!e){this.expandedRequestKey=null;return}let t=this.requestKey(e);this.expandedRequestKey!==t&&(this.expandedRequestKey=t,this.requestDetail(e)||this.$emit("select-request",e))},toolHasDetail(e){return e?.input!=null||e?.output!=null},refreshRequests(){this.$emit("refresh-requests")}},template:`
|
|
5080
|
+
`,data(){return{form:{provider:["yeaft","copilot","claude-code"].includes(this.initialProvider)?this.initialProvider:"yeaft",name:"",vpIds:[],defaultVpId:null,workDir:"",agentId:null},busy:!1,submitError:"",...Ja(),vpPickerTouched:!1,vpRosterOpen:!1,vpRosterPlacement:"down",vpRosterAvailableHeight:null,scannedSessions:[],restoreScanning:!1,restoring:null,restoreError:"",vpSnapshotTimer:null}},computed:{chat(){try{if(typeof window<"u"&&window.Pinia?.useChatStore)return window.Pinia.useChatStore()}catch{}return null},vpStore(){try{if(typeof window<"u"&&window.Pinia?.useVpStore)return window.Pinia.useVpStore()}catch{}return null},sessionsStore(){try{if(typeof window<"u"&&window.Pinia?.useSessionsStore)return window.Pinia.useSessionsStore()}catch{}return null},isYeaftProvider(){return this.form.provider==="yeaft"},vpLibraryReady(){let e=this.vpStore;return!!(e&&e.snapshotStatus==="ready"&&e.snapshotAgentId===this.form.agentId&&e.lastVpSnapshotAgentId===this.form.agentId)},vpList(){return this.vpLibraryReady?this.vpStore?.vpList||[]:[]},vpDomainSections(){return hs(this.vpList)},vpListSignature(){return(this.vpList||[]).map(e=>e&&e.vpId).filter(Boolean).join(",")},vpLibraryEmpty(){let e=this.vpStore;return!e||!this.vpLibraryReady?!1:e.emptyLibrary===!0?!0:!!(e.lastSnapshotAt&&e.lastSnapshotAt>0&&(e.vpOrder?.length||0)===0)},vpLibraryError(){let e=this.vpStore;return!e||e.snapshotStatus!=="error"?!1:!e.snapshotAgentId||e.snapshotAgentId===this.form.agentId},agentOptions(){let e=this.chat;return!e||!Array.isArray(e.agents)?[]:e.agents.map(t=>({id:t.id,name:t.name,online:!!t.online,workDir:t.workDir||""}))},agentSignature(){return this.agentOptions.map(e=>`${e.id}:${e.online?1:0}`).join(",")},folderPickerAgentId(){return this.form.agentId||this.chat?.currentAgent||""},defaultWorkDir(){return this.agentOptions.find(t=>t.id===this.form.agentId)?.workDir||this.chat?.currentAgentInfo?.workDir||""},workDirPlaceholder(){return this.defaultWorkDir||this.$t("modal.newConv.inputOrSelect")},allSessions(){return this.sessionsStore?.sessionList||[]},agentSessions(){let e=this.form.agentId||null;return e?this.allSessions.filter(t=>{let s=t&&t.agentId;return!s||s===e}):this.allSessions},folderAggregates(){let e=new Map;for(let t of this.agentSessions){let s=t&&typeof t.workDir=="string"?t.workDir.trim():"";if(!s)continue;let n=e.get(s)||{path:s,count:0};n.count+=1,e.set(s,n)}return Array.from(e.values()).sort((t,s)=>t.path.localeCompare(s.path))},sessionsInDir(){let e=this.form.agentId||null;return(Array.isArray(this.scannedSessions)?this.scannedSessions:[]).filter(s=>s&&s.id).map(s=>{let n=s.agentId||e,r=dt(n,s.id),i=!!(r&&this.sessionsStore?.sessions?.[r]);return{...s,...n?{agentId:n}:{},inSidebar:i}})},chatFolderRows(){return(this.chat?.folders||[]).map(e=>({path:e.path||e.name||"",count:Number(e.sessionCount)||0})).filter(e=>e.path)},createFolderRows(){return this.isYeaftProvider?this.folderAggregates:this.chatFolderRows},createSessionRows(){return this.isYeaftProvider?this.sessionsInDir:(this.chat?.historySessions||[]).map(e=>({...e,id:e.sessionId,name:e.title,createdAt:e.lastModified}))},canSubmit(){if(this.isYeaftProvider&&(!this.vpLibraryReady||this.form.vpIds.length===0)||!this.form.agentId)return!1;let e=this.agentOptions.find(t=>t.id===this.form.agentId);return!!(e&&e.online)},vpRosterSummary(){let e=this.form.vpIds||[];return e.length===0?this.$t("yeaft.session.create.vpNone"):e.length<=3?e.map(t=>this.vpLabelFor(t)).join(this.$t("common.comma")):this.$t("yeaft.session.create.vpCount",{n:e.length})},vpRosterPopupStyle(){return Number.isFinite(this.vpRosterAvailableHeight)?{"--vp-roster-available-height":`${this.vpRosterAvailableHeight}px`}:{}}},mounted(){window.addEventListener("keydown",this.onEsc),window.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.addEventListener("scroll",this.scheduleVpRosterLayout),window.addEventListener("workbench-message",this.handleFolderPickerMessage),document.addEventListener("click",this.handleOutsideRosterClick,!0),this.seedAgentDefault(),this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()},watch:{vpListSignature(){this.applyDefaultSelection(),this.scheduleVpRosterLayout()},agentSignature(){this.seedAgentDefault(),this.scheduleVpRosterLayout()},"form.provider"(e,t){e!==t&&(this.form.workDir="",this.scannedSessions=[],this.restoreError="",e==="yeaft"?(this.subscribeVpsFor(this.form.agentId),this.applyDefaultSelection()):this.form.agentId&&this.chat?.listFoldersForAgent?.(this.form.agentId,e))},"form.agentId"(e,t){e!==t&&(this.isYeaftProvider&&this.subscribeVpsFor(e),this.form.vpIds=[],this.form.defaultVpId=null,this.vpPickerTouched=!1,this.isYeaftProvider&&this.applyDefaultSelection(),this.scannedSessions=[],this.restoreError="",!this.isYeaftProvider&&e&&this.chat?.listFoldersForAgent?.(e,this.form.provider),(this.form.workDir||"").trim()&&this.loadProviderSessions())},"form.workDir"(e,t){e===t||(this.restoreError="",this.scannedSessions=[],!(e||"").trim())||this.loadProviderSessions()}},beforeUnmount(){window.removeEventListener("keydown",this.onEsc),window.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("resize",this.scheduleVpRosterLayout),window.visualViewport?.removeEventListener("scroll",this.scheduleVpRosterLayout),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),document.removeEventListener("click",this.handleOutsideRosterClick,!0),this._vpRosterLayoutFrame&&cancelAnimationFrame(this._vpRosterLayoutFrame),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer)},methods:{toggleVpRoster(){if(this.vpRosterOpen){this.closeVpRoster();return}this.vpRosterPlacement="down",this.vpRosterAvailableHeight=null,this.vpRosterOpen=!0,this.$nextTick(this.scheduleVpRosterLayout)},closeVpRoster(){this.vpRosterOpen=!1,this.vpRosterAvailableHeight=null},scheduleVpRosterLayout(){!this.vpRosterOpen||this._vpRosterLayoutFrame||(this._vpRosterLayoutFrame=requestAnimationFrame(()=>{this._vpRosterLayoutFrame=null,this.updateVpRosterLayout()}))},updateVpRosterLayout(){if(!this.vpRosterOpen)return;let e=this.$refs.vpRosterTrigger,t=this.$refs.vpRosterPopup,s=e?.closest?.(".resume-modal");if(!e||!t||!s)return;let n=t.style.maxHeight;t.style.maxHeight="none";let r=t.scrollHeight;t.style.maxHeight=n;let i=window.visualViewport,o=i?i.offsetTop:0,a=i?i.height:window.innerHeight,l={top:o,bottom:o+a},c=s.getBoundingClientRect(),d=my(e.getBoundingClientRect(),c,l,r);this.vpRosterPlacement=d.placement,this.vpRosterAvailableHeight=d.availableHeight},seedAgentDefault(){try{let e=this.agentOptions;if(!Array.isArray(e)||e.length===0||e.find(i=>i.id===this.form.agentId&&i.online))return;let s=this.chat,n=s&&s.currentAgent||null,r=e.find(i=>i.id===n&&i.online)||e.find(i=>i.online)||null;r&&(this.form.agentId=r.id)}catch{}},subscribeVpsFor(e,{force:t=!1}={}){let s=this.chat,n=e||s?.currentAgent||null,r=this.vpStore;if(!s||typeof s.sendWsMessage!="function"||!n){let l=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,l),r?.failSnapshot?.(n,l,"No online Agent is available."),!1}if(!t&&r?.snapshotStatus==="ready"&&r.snapshotAgentId===n&&r.lastVpSnapshotAgentId===n)return this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=null,!0;let o=`vp_snapshot_${Date.now()}_${Math.random().toString(36).slice(2,8)}`;return r?.beginSnapshot?.(n,o),s.sendWsMessage({type:"yeaft_vp_subscribe",agentId:n,requestId:o})===!1?(r?.failSnapshot?.(n,o,"WebSocket is not connected."),!1):(this.vpSnapshotTimer&&clearTimeout(this.vpSnapshotTimer),this.vpSnapshotTimer=setTimeout(()=>{this.vpSnapshotTimer=null,r?.snapshotStatus==="loading"&&r.snapshotRequestId===o&&r.failSnapshot(n,o,"VP library request timed out.")},1e4),!0)},retryVpSnapshot(){this.subscribeVpsFor(this.form.agentId,{force:!0})},loadProviderSessions(){if(this.isYeaftProvider)return this.loadRestoreCandidates();let e=(this.form.workDir||"").trim();!e||!this.form.agentId||this.chat?.listHistorySessionsForAgent?.(this.form.agentId,e,this.form.provider)},async loadRestoreCandidates(){if(this.restoreScanning)return;let e=(this.form.workDir||"").trim();if(!e){this.scannedSessions=[];return}let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:"no agent selected"});return}this.restoreScanning=!0,this.restoreError="";try{let n=await t.sessionCrudRequest("scan_workdir",{workDir:e},{agentId:s});if(n&&n.ok){let r=Array.isArray(n.sessions)?n.sessions:Array.isArray(n.groups)?n.groups:[];this.scannedSessions=r}else{this.scannedSessions=[];let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:r})}}catch(n){this.scannedSessions=[],this.restoreError=this.$t("yeaft.restore.modal.scanError",{message:n?.message||String(n)})}finally{this.restoreScanning=!1}},async onRestoreClick(e){if(!e||!e.id||this.restoring)return;let t=this.chat;if(!t||typeof t.sessionCrudRequest!="function"){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"store unavailable"});return}let s=this.form.agentId||null;if(!s){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:"no agent selected"});return}this.restoring=e.id,this.restoreError="";try{let n=await t.sessionCrudRequest("restore",{sessionId:e.id,workDir:(this.form.workDir||"").trim()},{agentId:s});if(n&&n.ok){let i=n.session||n.group||e,o=i?.agentId||e.agentId||s;o&&t.currentAgent!==o&&typeof t.selectAgent=="function"&&t.selectAgent(o),this.sessionsStore&&this.sessionsStore.setActive(i.id||e.id,o),typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(i.id||e.id,{agentId:o,force:!0}),this.$emit("created",i),this.$emit("close");return}let r=n?.error?.message||n?.error?.code||"unknown";this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:r})}catch(n){this.restoreError=this.$t("yeaft.restore.modal.restoreError",{message:n?.message||String(n)})}finally{this.restoring=null}},applyDefaultSelection(){if(this.vpPickerTouched)return;let e=this.vpList||[];if(e.length===0)return;let t=e.map(o=>o&&o.vpId).filter(Boolean);if(t.length===0)return;let s=Array.isArray(this.form.vpIds)?this.form.vpIds:[],n=s.filter(o=>t.includes(o)),r=this.form.defaultVpId&&n.includes(this.form.defaultVpId);if(n.length>0&&r){n.length!==s.length&&(this.form.vpIds=n);return}let i=t.includes(Yf)?Yf:n[0]||t[0];this.form.vpIds=[i],this.form.defaultVpId=i},toggleVp(e,t){this.vpPickerTouched=!0,t?(this.form.vpIds.includes(e)||this.form.vpIds.push(e),this.form.defaultVpId||(this.form.defaultVpId=e)):(this.form.vpIds=this.form.vpIds.filter(s=>s!==e),this.form.defaultVpId&&!this.form.vpIds.includes(this.form.defaultVpId)&&(this.form.defaultVpId=this.form.vpIds[0]||null))},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},vpTextColorFor(e){let t=this.vpStore?.vpTextColor;return typeof t=="function"?t(e):"var(--text-primary)"},selectFolder(e){this.form.workDir=e},selectSession(e){if(!(!e||!e.id)){if(!this.isYeaftProvider){let t=e.workDir||(this.form.workDir||"").trim()||this.defaultWorkDir;this.chat?.selectAgent?.(this.form.agentId),this.chat._pendingSessionTitle=e.name||e.title||null,this.chat?.resumeConversation?.(e.id,t,this.form.agentId,this.chatProviderOptions()),this.$emit("close");return}e.inSidebar?this.resumeExisting(e):this.onRestoreClick(e)}},chatProviderOptions(){let e={provider:this.form.provider};return this.form.provider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeExisting(e){if(!e||!e.id)return;let t=this.chat,s=e.agentId||this.form.agentId||null;s&&t&&t.currentAgent!==s&&typeof t.selectAgent=="function"&&t.selectAgent(s),this.sessionsStore&&this.sessionsStore.setActive(e.id,s),t&&typeof t.setActiveSessionFilter=="function"&&t.setActiveSessionFilter(e.id,{agentId:s,force:!0}),this.$emit("close")},handleOutsideRosterClick(e){if(!this.vpRosterOpen)return;let t=this.$refs.vpRosterRoot;t&&(t.contains(e.target)||this.closeVpRoster())},getLastPathSegment(e){return Zn(e)},formatDate(e){return Ri(e,this.$t.bind(this))},onEsc(e){if(e.key==="Escape"&&!this.folderPickerOpen){if(this.vpRosterOpen){this.closeVpRoster();return}this.busy||this.requestClose()}},onOverlayClick(){this.busy||this.requestClose()},requestClose(){this.$emit("close")},folderPickerInitialDir(){return this.form.workDir||this.defaultWorkDir||""},folderPickerSetWorkDir(e){this.form.workDir=e},...el,async onSubmit(){if(!(this.busy||!this.canSubmit)){this.submitError="",this.busy=!0;try{if(!this.chat){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}if(!this.isYeaftProvider){let d=this.form.workDir.trim()||this.defaultWorkDir;this.chat.selectAgent?.(this.form.agentId),this.chat.createConversation?.(d,this.form.agentId,null,this.chatProviderOptions()),this.$emit("created",{provider:this.form.provider,workDir:d}),this.$emit("close");return}if(typeof this.chat.createYeaftSession!="function"){this.submitError=this.$t("yeaft.session.error.unknown",{message:"store unavailable"});return}let e=new Set((this.vpList||[]).map(d=>d&&d.vpId).filter(Boolean)),t=this.form.vpIds.filter(d=>e.has(d));if(t.length===0){this.submitError=this.$t("yeaft.session.error.unknown",{message:"no valid VP selected"});return}let s=this.form.defaultVpId&&t.includes(this.form.defaultVpId)?this.form.defaultVpId:t[0],r=this.form.name.trim()||Zn(this.form.workDir.trim())||this.$t("yeaft.session.create.untitled"),i=await this.chat.createYeaftSession({displayName:r,vpIds:t,defaultVpId:s,workDir:this.form.workDir.trim(),agentId:this.form.agentId||null});if(i&&i.ok){let d=this.chat,u=i.session||i.group||null,f=u&&u.id,p=u?.agentId||this.form.agentId||null;f&&(p&&d&&d.currentAgent!==p&&typeof d.selectAgent=="function"&&d.selectAgent(p),this.sessionsStore&&this.sessionsStore.setActive(f,p),d&&typeof d.setActiveSessionFilter=="function"&&d.setActiveSessionFilter(f,{agentId:p,force:!0})),this.$emit("created",u),this.$emit("close");return}let o=i?.error?.code||"unknown",a=i?.error?.message||"",l=`yeaft.session.error.${o}`,c=this.$t(l,{message:a});this.submitError=c===l?this.$t("yeaft.session.error.unknown",{message:a}):c}catch(e){this.submitError=this.$t("yeaft.session.error.unknown",{message:e?.message||String(e)})}finally{this.busy=!1}}}}}});function bs(e){return!e?.runId||!e?.id?"":`${e.runId}:${e.id}`}function Qf(e,t){let s=bs(e);return s?`${s}:${t?.id||t?.loopNumber||""}`:""}var sl=F(()=>{});var Xf,Zf=F(()=>{Nn();sl();Xf={name:"WorkCenterActionDetail",props:{action:{type:Object,default:null},selected:{type:Object,default:null},messages:{type:Array,default:()=>[]},messagesNextCursor:{type:[String,Number],default:null},messagesLoading:{type:Boolean,default:!1},messagesError:{type:String,default:""},requests:{type:Array,default:()=>[]},requestDetails:{type:Object,default:()=>({})},requestDetailsLoading:{type:Object,default:()=>({})},requestDetailsError:{type:Object,default:()=>({})},requestsLoading:{type:Boolean,default:!1},requestsError:{type:String,default:""},previewingAttachmentId:{type:String,default:null},attachmentError:{type:String,default:""}},emits:["back","target-action","load-earlier-messages","select-request","refresh-requests","open-run","open-attachment"],data(){return{activeView:"conversation",conversationScrollTop:0,expandedRequestKey:null,requestSelectionTouched:!1}},computed:{executorName(){return this.action?.assignedVp?.name||this.action?.assignedVp?.id||this.action?.requiredRole||this.tr("workCenter.actionExecutorPending","Executor pending")},canTargetAction(){return!this.action||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(this.action.status)&&this.action.admissionStatus!=="blocked"},hasMessages(){return this.messages.length>0},hasActionBrief(){return!!this.action?.brief?.approach||!!this.action?.brief?.expectedOutcome||!!this.action?.dependsOnStageIds?.length||!!this.action?.canonicalResult?.summary},waitingQuestion(){return this.action?.status!=="waiting"?"":String(this.action?.canonicalResult?.waitingReason||"").trim()},currentGenerationRequests(){let e=Math.max(1,Number(this.action?.generation)||1);return this.requests.filter(t=>Math.max(1,Number(t?.generation)||1)===e).slice().sort((t,s)=>(Number(s?.attempt)||0)-(Number(t?.attempt)||0)||(Number(s?.openedAt)||0)-(Number(t?.openedAt)||0)||String(s?.id||"").localeCompare(String(t?.id||"")))}},watch:{"action.id"(){this.resetActionView()},"action.generation"(e,t){let s=Math.max(1,Number(e)||1),n=Math.max(1,Number(t)||1);s!==n&&this.resetActionView()},messages:{deep:!0,handler(){this.$nextTick(()=>Ye(this.$el))}},requests(){this.activeView!=="execution"||this.requestSelectionTouched||this.$nextTick(()=>this.syncLatestRequest())}},mounted(){this.$nextTick(()=>Ye(this.$el))},methods:{tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},messageSpeaker(e){return e?.role==="user"?this.tr("workCenter.you","You"):e?.speaker?.name||e?.speaker?.id||this.executorName},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},formatDuration(e){let t=Math.max(0,Number(e)||0);return t<1e3?`${t}ms`:`${(t/1e3).toFixed(t<1e4?1:0)}s`},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},messageHtml(e){return ii(String(e||""))},json(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}},requestKey(e){return bs(e)},requestLoopKey(e,t){return Qf(e,t)},requestDetail(e){let t=this.requestDetails[this.requestKey(e)]||null;return t?.request||t},resetActionView(){this.activeView="conversation",this.conversationScrollTop=0,this.expandedRequestKey=null,this.requestSelectionTouched=!1,this.$nextTick(()=>{this.$refs.conversationPanel&&(this.$refs.conversationPanel.scrollTop=0),Ye(this.$el)})},tabId(e){return`work-center-action-${e}-tab`},panelId(e){return`work-center-action-${e}-panel`},onTabKeydown(e,t){let s=["conversation","execution"],n=s.indexOf(t);if(n<0)return;let r;if(e.key==="ArrowRight")r=(n+1)%s.length;else if(e.key==="ArrowLeft")r=(n-1+s.length)%s.length;else if(e.key==="Home")r=0;else if(e.key==="End")r=s.length-1;else return;e.preventDefault();let i=s[r];this.setActiveView(i),this.$nextTick(()=>this.$refs[`${i}Tab`]?.focus())},async openRun(e){let t=this.action?.id,s=this.action?.generation,n=await new Promise(r=>this.$emit("open-run",e,r));!n||this.action?.id!==t||this.action?.generation!==s||(this.activeView="execution",this.requestSelectionTouched=!0,this.expandedRequestKey=this.requestKey(n),await this.$nextTick(),this.$refs.requestsPanel?.scrollIntoView?.({behavior:"smooth",block:"start"}))},setActiveView(e){e!==this.activeView&&(this.activeView==="conversation"&&(this.conversationScrollTop=this.$refs.conversationPanel?.scrollTop||0),this.activeView=e,e==="execution"&&(this.refreshRequests(),this.$nextTick(()=>this.syncLatestRequest())),this.$nextTick(()=>{e==="conversation"&&this.$refs.conversationPanel&&(this.$refs.conversationPanel.scrollTop=this.conversationScrollTop),Ye(this.$el)}))},async toggleRequest(e){let t=this.requestKey(e);if(this.requestSelectionTouched=!0,this.expandedRequestKey===t){this.expandedRequestKey=null;return}this.expandedRequestKey=t,this.requestDetail(e)||this.$emit("select-request",e)},syncLatestRequest(){if(this.requestSelectionTouched)return;let e=this.currentGenerationRequests[0];if(!e){this.expandedRequestKey=null;return}let t=this.requestKey(e);this.expandedRequestKey!==t&&(this.expandedRequestKey=t,this.requestDetail(e)||this.$emit("select-request",e))},toolHasDetail(e){return e?.input!=null||e?.output!=null},refreshRequests(){this.$emit("refresh-requests")}},template:`
|
|
5086
5081
|
<section class="work-center-action-detail-pane" v-if="action">
|
|
5087
5082
|
<header class="work-center-action-detail-header">
|
|
5088
5083
|
<div class="work-center-action-header-copy">
|
|
@@ -5231,7 +5226,7 @@ ${String(e||"").trim()}
|
|
|
5231
5226
|
</div>
|
|
5232
5227
|
</section>
|
|
5233
5228
|
<section v-else class="work-center-action-detail-pane work-center-detail-empty"><strong>{{ tr('workCenter.selectAction', 'Select an Action to inspect its execution') }}</strong></section>
|
|
5234
|
-
`}});function rl(e){return JSON.parse(JSON.stringify(e))}function my(e,t=[]){return{mode:"auto",capability:e,candidateVpIds:[],fixedVpId:null,separateFromStageTypes:t}}function Ei(e,t,s,n={}){return{id:e,name:t,type:s,instruction:"",assignmentPolicy:my(s,n.separateFromStageTypes),modelPolicy:{mode:"inherit",model:null,effort:null},maxAttempts:2,...n.changesRequestedStageId?{changesRequestedStageId:n.changesRequestedStageId}:{}}}function nl(){return{version:1,revision:1,defaultWorkflowId:"software-change",startImmediately:!0,maxConcurrentActions:3,defaultWorkDir:"",globalInstructions:"",modelPolicy:{mode:"inherit",model:null,effort:null},coordinatorModelPolicy:{mode:"inherit",model:null,effort:"high"},actionModelPolicies:Object.fromEntries(ws.map(e=>[e,{mode:"inherit",model:null,effort:["triage","research","design","diagnose","review"].includes(e)?"high":"medium"}])),actionInstructions:Object.fromEntries(ws.map(e=>[e,""])),workflows:[{version:1,id:"software-change",name:"Software change",stages:[Ei("triage","Triage","triage"),Ei("implement","Implement","implement"),Ei("review","Review","review",{separateFromStageTypes:["implement"],changesRequestedStageId:"implement"}),Ei("deliver","Deliver","deliver")]}]}}function Li(e){return!e||typeof e!="object"||Array.isArray(e)||!e.modelPolicy||typeof e.modelPolicy!="object"||Array.isArray(e.modelPolicy)||!e.coordinatorModelPolicy||typeof e.coordinatorModelPolicy!="object"||Array.isArray(e.coordinatorModelPolicy)||typeof e.globalInstructions!="string"||!e.actionInstructions||typeof e.actionInstructions!="object"||Array.isArray(e.actionInstructions)||!e.actionModelPolicies||typeof e.actionModelPolicies!="object"||Array.isArray(e.actionModelPolicies)?!1:ws.every(t=>typeof e.actionInstructions[t]=="string")}function hy(e,t){return Li(e)&&Number.isInteger(e.revision)&&Number.isInteger(t)&&e.revision>t}function Di(e,t={}){let s=e&&typeof e=="object"&&!Array.isArray(e)?rl(e):{},n=Array.isArray(s.workflows)&&s.workflows.length>0?s.workflows:nl().workflows,r=n.find(c=>c?.id===s.defaultWorkflowId)||n[0]||null,i=Array.isArray(r?.stages)?r.stages:[],o=Object.fromEntries(i.filter(c=>ws.includes(c?.type)&&typeof c.instruction=="string").map(c=>[c.type,c.instruction])),a=s.actionInstructions&&typeof s.actionInstructions=="object"&&!Array.isArray(s.actionInstructions)?s.actionInstructions:{},l=i.find(c=>c?.type==="triage")?.modelPolicy||i[0]?.modelPolicy;return{...nl(),...s,modelPolicy:{mode:"inherit",model:null,effort:null,...l||{},...s.modelPolicy||{}},coordinatorModelPolicy:{mode:"inherit",model:null,effort:"high",...s.coordinatorModelPolicy||{}},actionModelPolicies:Object.fromEntries(ws.map(c=>[c,{...nl().actionModelPolicies[c],...s.actionModelPolicies?.[c]||{}}])),actionInstructions:Object.fromEntries(ws.map(c=>[c,typeof a[c]=="string"?a[c]:o[c]||t[c]||""])),workflows:n}}function vy(e){let t=e?.message||String(e);return/^Unsupported Work Center operation:\s*get_settings$/i.test(t.trim())}var ws,Jf,eg=F(()=>{vs();ws=["triage","research","design","diagnose","implement","migrate","test","review","integrate","document","operate","deliver","write","custom"];Jf={name:"WorkCenterSettingsModal",emits:["close","saved","open-agent-models"],props:{agentId:{type:String,required:!0}},data(){return{section:"workflow",draft:null,loading:!0,saving:!1,error:"",conflict:!1,settingsUnsupported:!1,draftAgentId:null,loadGeneration:0}},computed:{store(){return Pinia.useChatStore()},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||{}},vps(){return Array.isArray(this.runtime.vps)?this.runtime.vps:[]},models(){return Array.isArray(this.runtime.models)?this.runtime.models:[]},workflows(){return Array.isArray(this.draft?.workflows)?this.draft.workflows:[]},actionTypes(){return ws},defaultWorkflow(){return this.workflows.find(e=>e.id===this.draft?.defaultWorkflowId)||this.workflows[0]||null},defaultStageInstructions(){return this.runtime.defaultStageInstructions||{}},sections(){return[{id:"workflow",label:this.$t("workCenter.settings.workflow")},{id:"models",label:this.$t("workCenter.settings.models")}]}},watch:{runtime:{deep:!0,handler(){this.normalizeDraftEffort()}}},async mounted(){window.addEventListener("keydown",this.onKeydown);let e=this.store.workCenterSettingsByAgent[this.agentId];e&&(this.draft=Di(e,this.defaultStageInstructions),this.normalizeDraftEffort(),this.draftAgentId=this.agentId,this.settingsUnsupported=!Li(e),this.settingsUnsupported&&(this.error=this.$t("workCenter.settings.upgradeRequired")),this.loading=!1),await this.load()},beforeUnmount(){window.removeEventListener("keydown",this.onKeydown)},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,async load(){let e=this.agentId,t=++this.loadGeneration;this.loading=!0,this.error=this.settingsUnsupported&&this.draft?this.$t("workCenter.settings.upgradeRequired"):"";try{let s=await this.store.loadWorkCenterSettings(e);if(t!==this.loadGeneration||e!==this.agentId)return;this.draft=Di(s.settings,this.defaultStageInstructions),this.normalizeDraftEffort(),this.draftAgentId=e,this.conflict=!1,this.settingsUnsupported=!Li(s.settings),this.error=this.settingsUnsupported?this.$t("workCenter.settings.upgradeRequired"):""}catch(s){if(t!==this.loadGeneration||e!==this.agentId)return;vy(s)?(this.draft=Di(null,this.defaultStageInstructions),this.draftAgentId=e,this.settingsUnsupported=!0,this.error=this.$t("workCenter.settings.upgradeRequired")):this.error=s?.message||String(s)}finally{t===this.loadGeneration&&e===this.agentId&&(this.loading=!1)}},onKeydown(e){e.key==="Escape"&&!this.saving&&this.$emit("close")},onOverlayClick(e){Ze(e)&&this.close()},close(){this.saving||this.$emit("close")},vpLabel(e){return this.$i18n?.locale==="zh-CN"&&e.nameZh?e.nameZh:e.name||e.id},setAssignmentMode(e,t){e.assignmentPolicy.mode=t,t==="fixed"&&!e.assignmentPolicy.fixedVpId&&(e.assignmentPolicy.fixedVpId=this.vps[0]?.id||null),t==="pool"&&e.assignmentPolicy.candidateVpIds.length===0&&this.vps[0]&&(e.assignmentPolicy.candidateVpIds=[this.vps[0].id])},addWorkflow(){let e=this.workflows.length+1,t=this.defaultWorkflow||this.workflows[0],s=t?rl(t):{version:1,stages:[]};s.id=`workflow-${Date.now()}`,s.name=this.$t("workCenter.settings.newWorkflow",{index:e}),this.draft.workflows.push(s),this.draft.defaultWorkflowId=s.id},removeWorkflow(){this.workflows.length<=1||!this.defaultWorkflow||(this.draft.workflows=this.workflows.filter(e=>e.id!==this.defaultWorkflow.id),this.draft.defaultWorkflowId=this.draft.workflows[0].id)},addStage(){if(!this.defaultWorkflow)return;let e=`stage-${Date.now()}`;this.defaultWorkflow.stages.push({id:e,name:this.$t("workCenter.settings.newStage"),type:"custom",instruction:this.defaultStageInstructions.custom||"",assignmentPolicy:{mode:"auto",capability:"custom",candidateVpIds:[],fixedVpId:null,separateFromStageTypes:[]},modelPolicy:{mode:"inherit",model:null,effort:null},maxAttempts:2})},moveStage(e,t){let s=this.defaultWorkflow?.stages,n=e+t;if(!s||n<0||n>=s.length)return;let[r]=s.splice(e,1);s.splice(n,0,r)},reviewReturnCandidates(e){let t=this.defaultWorkflow?.stages||[],s=t.findIndex(n=>n.id===e.id);return s<=0?[]:t.slice(0,s).filter(n=>n.type!=="review"&&n.type!=="deliver")},canRemoveStage(e){let t=this.defaultWorkflow?.stages;if(!t||t.length<=1)return!1;let s=t[e],n=t.filter((r,i)=>i!==e);return n.every((r,i)=>r.type!=="review"||r.changesRequestedStageId!==s.id?!0:n.slice(0,i).some(o=>o.type!=="review"&&o.type!=="deliver"))},removeStage(e){let t=this.defaultWorkflow?.stages;if(!t||!this.canRemoveStage(e))return!1;let[s]=t.splice(e,1);for(let[n,r]of t.entries()){if(r.type!=="review"||r.changesRequestedStageId!==s.id)continue;let i=t.slice(0,n).filter(o=>o.type!=="review"&&o.type!=="deliver");r.changesRequestedStageId=i.at(-1).id}return!0},toggleCandidate(e,t,s){let n=new Set(e.assignmentPolicy.candidateVpIds||[]);s?n.add(t):n.delete(t),e.assignmentPolicy.candidateVpIds=[...n]},defaultInstructionForStage(e){return this.defaultStageInstructions[e.type]||this.defaultStageInstructions.custom||""},resetStageInstruction(e){e.instruction=this.defaultInstructionForStage(e)},setStageType(e,t){let s=this.defaultInstructionForStage(e),n=!e.instruction||e.instruction===s;e.type=t,n&&this.resetStageInstruction(e)},modelRefForStage(e){return e.modelPolicy.mode==="specific"?e.modelPolicy.model:e.modelPolicy.mode==="primary"?this.runtime.primaryModel||null:e.modelPolicy.mode==="fast"&&this.runtime.fastModel||null},modelForStage(e){let t=this.modelRefForStage(e);return t&&this.models.find(s=>(s.ref||s.id)===t)||null},effortOptionsForStage(e){let t=this.modelForStage(e);return t?Array.isArray(t.effortOptions)?t.effortOptions:[]:e.modelPolicy.mode==="inherit"?[...new Set(this.models.flatMap(s=>Array.isArray(s.effortOptions)?s.effortOptions:[]))]:[]},effortHelpKeyForStage(e){return this.modelRefForStage(e)?this.effortOptionsForStage(e).length===0?"workCenter.settings.effortUnsupportedHelp":"workCenter.settings.effortHelp":"workCenter.settings.effortChooseModelHelp"},normalizeStageEffort(e){let t=this.effortOptionsForStage(e);!e.modelPolicy.effort||t.includes(e.modelPolicy.effort)||(e.modelPolicy.effort=null)},normalizeDraftEffort(){if(!(!this.draft?.modelPolicy||!Array.isArray(this.runtime?.models))){this.normalizeStageEffort({modelPolicy:this.draft.modelPolicy}),this.normalizeStageEffort({modelPolicy:this.draft.coordinatorModelPolicy});for(let e of Object.values(this.draft.actionModelPolicies||{}))this.normalizeStageEffort({modelPolicy:e})}},setModelMode(e,t){e.modelPolicy.mode=t,t==="specific"&&!e.modelPolicy.model&&(e.modelPolicy.model=this.models[0]?.ref||this.models[0]?.id||null),this.normalizeStageEffort(e)},setStageModel(e,t){e.modelPolicy.model=t||null,this.normalizeStageEffort(e)},async save(){if(!this.draft||this.saving||this.settingsUnsupported)return;let e=this.agentId;if(this.draftAgentId!==e){this.conflict=!0,this.error=this.$t("workCenter.settings.conflict");return}this.saving=!0,this.error="",this.conflict=!1;try{this.normalizeDraftEffort();let t=rl(this.draft),s=await this.store.saveWorkCenterSettings(t,e);if(e!==this.agentId||this.draftAgentId!==e)return;if(!hy(s.settings,t.revision)){this.settingsUnsupported=!Li(s.settings),this.error=this.$t(this.settingsUnsupported?"workCenter.settings.upgradeRequired":"workCenter.settings.saveNotConfirmed");return}this.draft=Di(s.settings,this.defaultStageInstructions),this.$emit("saved",s.settings),this.$emit("close")}catch(t){if(e!==this.agentId)return;let s=t?.message||String(t);this.conflict=/changed elsewhere|reload before saving/i.test(s),this.error=this.conflict?this.$t("workCenter.settings.conflict"):s}finally{e===this.agentId&&(this.saving=!1)}}},template:`
|
|
5229
|
+
`}});function rl(e){return JSON.parse(JSON.stringify(e))}function hy(e,t=[]){return{mode:"auto",capability:e,candidateVpIds:[],fixedVpId:null,separateFromStageTypes:t}}function Ei(e,t,s,n={}){return{id:e,name:t,type:s,instruction:"",assignmentPolicy:hy(s,n.separateFromStageTypes),modelPolicy:{mode:"inherit",model:null,effort:null},maxAttempts:2,...n.changesRequestedStageId?{changesRequestedStageId:n.changesRequestedStageId}:{}}}function nl(){return{version:1,revision:1,defaultWorkflowId:"software-change",startImmediately:!0,maxConcurrentActions:3,defaultWorkDir:"",globalInstructions:"",modelPolicy:{mode:"inherit",model:null,effort:null},coordinatorModelPolicy:{mode:"inherit",model:null,effort:"high"},actionModelPolicies:Object.fromEntries(ws.map(e=>[e,{mode:"inherit",model:null,effort:["triage","research","design","diagnose","review"].includes(e)?"high":"medium"}])),actionInstructions:Object.fromEntries(ws.map(e=>[e,""])),workflows:[{version:1,id:"software-change",name:"Software change",stages:[Ei("triage","Triage","triage"),Ei("implement","Implement","implement"),Ei("review","Review","review",{separateFromStageTypes:["implement"],changesRequestedStageId:"implement"}),Ei("deliver","Deliver","deliver")]}]}}function Li(e){return!e||typeof e!="object"||Array.isArray(e)||!e.modelPolicy||typeof e.modelPolicy!="object"||Array.isArray(e.modelPolicy)||!e.coordinatorModelPolicy||typeof e.coordinatorModelPolicy!="object"||Array.isArray(e.coordinatorModelPolicy)||typeof e.globalInstructions!="string"||!e.actionInstructions||typeof e.actionInstructions!="object"||Array.isArray(e.actionInstructions)||!e.actionModelPolicies||typeof e.actionModelPolicies!="object"||Array.isArray(e.actionModelPolicies)?!1:ws.every(t=>typeof e.actionInstructions[t]=="string")}function vy(e,t){return Li(e)&&Number.isInteger(e.revision)&&Number.isInteger(t)&&e.revision>t}function Di(e,t={}){let s=e&&typeof e=="object"&&!Array.isArray(e)?rl(e):{},n=Array.isArray(s.workflows)&&s.workflows.length>0?s.workflows:nl().workflows,r=n.find(c=>c?.id===s.defaultWorkflowId)||n[0]||null,i=Array.isArray(r?.stages)?r.stages:[],o=Object.fromEntries(i.filter(c=>ws.includes(c?.type)&&typeof c.instruction=="string").map(c=>[c.type,c.instruction])),a=s.actionInstructions&&typeof s.actionInstructions=="object"&&!Array.isArray(s.actionInstructions)?s.actionInstructions:{},l=i.find(c=>c?.type==="triage")?.modelPolicy||i[0]?.modelPolicy;return{...nl(),...s,modelPolicy:{mode:"inherit",model:null,effort:null,...l||{},...s.modelPolicy||{}},coordinatorModelPolicy:{mode:"inherit",model:null,effort:"high",...s.coordinatorModelPolicy||{}},actionModelPolicies:Object.fromEntries(ws.map(c=>[c,{...nl().actionModelPolicies[c],...s.actionModelPolicies?.[c]||{}}])),actionInstructions:Object.fromEntries(ws.map(c=>[c,typeof a[c]=="string"?a[c]:o[c]||t[c]||""])),workflows:n}}function yy(e){let t=e?.message||String(e);return/^Unsupported Work Center operation:\s*get_settings$/i.test(t.trim())}var ws,Jf,eg=F(()=>{ys();ws=["triage","research","design","diagnose","implement","migrate","test","review","integrate","document","operate","deliver","write","custom"];Jf={name:"WorkCenterSettingsModal",emits:["close","saved","open-agent-models"],props:{agentId:{type:String,required:!0}},data(){return{section:"workflow",draft:null,loading:!0,saving:!1,error:"",conflict:!1,settingsUnsupported:!1,draftAgentId:null,loadGeneration:0}},computed:{store(){return Pinia.useChatStore()},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||{}},vps(){return Array.isArray(this.runtime.vps)?this.runtime.vps:[]},models(){return Array.isArray(this.runtime.models)?this.runtime.models:[]},workflows(){return Array.isArray(this.draft?.workflows)?this.draft.workflows:[]},actionTypes(){return ws},defaultWorkflow(){return this.workflows.find(e=>e.id===this.draft?.defaultWorkflowId)||this.workflows[0]||null},defaultStageInstructions(){return this.runtime.defaultStageInstructions||{}},sections(){return[{id:"workflow",label:this.$t("workCenter.settings.workflow")},{id:"models",label:this.$t("workCenter.settings.models")}]}},watch:{runtime:{deep:!0,handler(){this.normalizeDraftEffort()}}},async mounted(){window.addEventListener("keydown",this.onKeydown);let e=this.store.workCenterSettingsByAgent[this.agentId];e&&(this.draft=Di(e,this.defaultStageInstructions),this.normalizeDraftEffort(),this.draftAgentId=this.agentId,this.settingsUnsupported=!Li(e),this.settingsUnsupported&&(this.error=this.$t("workCenter.settings.upgradeRequired")),this.loading=!1),await this.load()},beforeUnmount(){window.removeEventListener("keydown",this.onKeydown)},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,async load(){let e=this.agentId,t=++this.loadGeneration;this.loading=!0,this.error=this.settingsUnsupported&&this.draft?this.$t("workCenter.settings.upgradeRequired"):"";try{let s=await this.store.loadWorkCenterSettings(e);if(t!==this.loadGeneration||e!==this.agentId)return;this.draft=Di(s.settings,this.defaultStageInstructions),this.normalizeDraftEffort(),this.draftAgentId=e,this.conflict=!1,this.settingsUnsupported=!Li(s.settings),this.error=this.settingsUnsupported?this.$t("workCenter.settings.upgradeRequired"):""}catch(s){if(t!==this.loadGeneration||e!==this.agentId)return;yy(s)?(this.draft=Di(null,this.defaultStageInstructions),this.draftAgentId=e,this.settingsUnsupported=!0,this.error=this.$t("workCenter.settings.upgradeRequired")):this.error=s?.message||String(s)}finally{t===this.loadGeneration&&e===this.agentId&&(this.loading=!1)}},onKeydown(e){e.key==="Escape"&&!this.saving&&this.$emit("close")},onOverlayClick(e){Ze(e)&&this.close()},close(){this.saving||this.$emit("close")},vpLabel(e){return this.$i18n?.locale==="zh-CN"&&e.nameZh?e.nameZh:e.name||e.id},setAssignmentMode(e,t){e.assignmentPolicy.mode=t,t==="fixed"&&!e.assignmentPolicy.fixedVpId&&(e.assignmentPolicy.fixedVpId=this.vps[0]?.id||null),t==="pool"&&e.assignmentPolicy.candidateVpIds.length===0&&this.vps[0]&&(e.assignmentPolicy.candidateVpIds=[this.vps[0].id])},addWorkflow(){let e=this.workflows.length+1,t=this.defaultWorkflow||this.workflows[0],s=t?rl(t):{version:1,stages:[]};s.id=`workflow-${Date.now()}`,s.name=this.$t("workCenter.settings.newWorkflow",{index:e}),this.draft.workflows.push(s),this.draft.defaultWorkflowId=s.id},removeWorkflow(){this.workflows.length<=1||!this.defaultWorkflow||(this.draft.workflows=this.workflows.filter(e=>e.id!==this.defaultWorkflow.id),this.draft.defaultWorkflowId=this.draft.workflows[0].id)},addStage(){if(!this.defaultWorkflow)return;let e=`stage-${Date.now()}`;this.defaultWorkflow.stages.push({id:e,name:this.$t("workCenter.settings.newStage"),type:"custom",instruction:this.defaultStageInstructions.custom||"",assignmentPolicy:{mode:"auto",capability:"custom",candidateVpIds:[],fixedVpId:null,separateFromStageTypes:[]},modelPolicy:{mode:"inherit",model:null,effort:null},maxAttempts:2})},moveStage(e,t){let s=this.defaultWorkflow?.stages,n=e+t;if(!s||n<0||n>=s.length)return;let[r]=s.splice(e,1);s.splice(n,0,r)},reviewReturnCandidates(e){let t=this.defaultWorkflow?.stages||[],s=t.findIndex(n=>n.id===e.id);return s<=0?[]:t.slice(0,s).filter(n=>n.type!=="review"&&n.type!=="deliver")},canRemoveStage(e){let t=this.defaultWorkflow?.stages;if(!t||t.length<=1)return!1;let s=t[e],n=t.filter((r,i)=>i!==e);return n.every((r,i)=>r.type!=="review"||r.changesRequestedStageId!==s.id?!0:n.slice(0,i).some(o=>o.type!=="review"&&o.type!=="deliver"))},removeStage(e){let t=this.defaultWorkflow?.stages;if(!t||!this.canRemoveStage(e))return!1;let[s]=t.splice(e,1);for(let[n,r]of t.entries()){if(r.type!=="review"||r.changesRequestedStageId!==s.id)continue;let i=t.slice(0,n).filter(o=>o.type!=="review"&&o.type!=="deliver");r.changesRequestedStageId=i.at(-1).id}return!0},toggleCandidate(e,t,s){let n=new Set(e.assignmentPolicy.candidateVpIds||[]);s?n.add(t):n.delete(t),e.assignmentPolicy.candidateVpIds=[...n]},defaultInstructionForStage(e){return this.defaultStageInstructions[e.type]||this.defaultStageInstructions.custom||""},resetStageInstruction(e){e.instruction=this.defaultInstructionForStage(e)},setStageType(e,t){let s=this.defaultInstructionForStage(e),n=!e.instruction||e.instruction===s;e.type=t,n&&this.resetStageInstruction(e)},modelRefForStage(e){return e.modelPolicy.mode==="specific"?e.modelPolicy.model:e.modelPolicy.mode==="primary"?this.runtime.primaryModel||null:e.modelPolicy.mode==="fast"&&this.runtime.fastModel||null},modelForStage(e){let t=this.modelRefForStage(e);return t&&this.models.find(s=>(s.ref||s.id)===t)||null},effortOptionsForStage(e){let t=this.modelForStage(e);return t?Array.isArray(t.effortOptions)?t.effortOptions:[]:e.modelPolicy.mode==="inherit"?[...new Set(this.models.flatMap(s=>Array.isArray(s.effortOptions)?s.effortOptions:[]))]:[]},effortHelpKeyForStage(e){return this.modelRefForStage(e)?this.effortOptionsForStage(e).length===0?"workCenter.settings.effortUnsupportedHelp":"workCenter.settings.effortHelp":"workCenter.settings.effortChooseModelHelp"},normalizeStageEffort(e){let t=this.effortOptionsForStage(e);!e.modelPolicy.effort||t.includes(e.modelPolicy.effort)||(e.modelPolicy.effort=null)},normalizeDraftEffort(){if(!(!this.draft?.modelPolicy||!Array.isArray(this.runtime?.models))){this.normalizeStageEffort({modelPolicy:this.draft.modelPolicy}),this.normalizeStageEffort({modelPolicy:this.draft.coordinatorModelPolicy});for(let e of Object.values(this.draft.actionModelPolicies||{}))this.normalizeStageEffort({modelPolicy:e})}},setModelMode(e,t){e.modelPolicy.mode=t,t==="specific"&&!e.modelPolicy.model&&(e.modelPolicy.model=this.models[0]?.ref||this.models[0]?.id||null),this.normalizeStageEffort(e)},setStageModel(e,t){e.modelPolicy.model=t||null,this.normalizeStageEffort(e)},async save(){if(!this.draft||this.saving||this.settingsUnsupported)return;let e=this.agentId;if(this.draftAgentId!==e){this.conflict=!0,this.error=this.$t("workCenter.settings.conflict");return}this.saving=!0,this.error="",this.conflict=!1;try{this.normalizeDraftEffort();let t=rl(this.draft),s=await this.store.saveWorkCenterSettings(t,e);if(e!==this.agentId||this.draftAgentId!==e)return;if(!vy(s.settings,t.revision)){this.settingsUnsupported=!Li(s.settings),this.error=this.$t(this.settingsUnsupported?"workCenter.settings.upgradeRequired":"workCenter.settings.saveNotConfirmed");return}this.draft=Di(s.settings,this.defaultStageInstructions),this.$emit("saved",s.settings),this.$emit("close")}catch(t){if(e!==this.agentId)return;let s=t?.message||String(t);this.conflict=/changed elsewhere|reload before saving/i.test(s),this.error=this.conflict?this.$t("workCenter.settings.conflict"):s}finally{e===this.agentId&&(this.saving=!1)}}},template:`
|
|
5235
5230
|
<Teleport to="body">
|
|
5236
5231
|
<div
|
|
5237
5232
|
class="modal-overlay work-center-settings-overlay"
|
|
@@ -5385,7 +5380,7 @@ ${String(e||"").trim()}
|
|
|
5385
5380
|
</section>
|
|
5386
5381
|
</div>
|
|
5387
5382
|
</Teleport>
|
|
5388
|
-
`}});var il,tg=F(()=>{il={anthropic:["claude-opus-4-8","claude-opus-4.8","claude-sonnet-4-20250514","claude-opus-4-20250514","claude-haiku-3-20250414"],openai:["gpt-5","gpt-4.1","gpt-4.1-mini","o3","o4-mini"],"openai-responses":["gpt-5","gpt-5-mini","gpt-5-nano","gpt-5-pro"]}});function
|
|
5383
|
+
`}});var il,tg=F(()=>{il={anthropic:["claude-opus-4-8","claude-opus-4.8","claude-sonnet-4-20250514","claude-opus-4-20250514","claude-haiku-3-20250414"],openai:["gpt-5","gpt-4.1","gpt-4.1-mini","o3","o4-mini"],"openai-responses":["gpt-5","gpt-5-mini","gpt-5-nano","gpt-5-pro"]}});function by(e){if(typeof e!="string"||!e)return null;let t=e.toLowerCase();return t.startsWith("claude")||t.includes("/claude")||t.includes(".claude")?"anthropic":/^(gpt-|o1|o3|o4|chatgpt-|codex-|omni-)/.test(t)?"openai-responses":null}var sg,ng=F(()=>{ys();sg={name:"ProviderPresetPicker",emits:["close","pick"],template:`
|
|
5389
5384
|
<div
|
|
5390
5385
|
class="llm-preset-modal-backdrop"
|
|
5391
5386
|
@pointerdown="trackOverlayPointerDown"
|
|
@@ -5465,7 +5460,7 @@ ${String(e||"").trim()}
|
|
|
5465
5460
|
</div>
|
|
5466
5461
|
</div>
|
|
5467
5462
|
</div>
|
|
5468
|
-
`,data(){return{loading:!1,error:null,registry:{},fetchedAt:0,providerFilter:"",modelFilter:"",selectedProviderId:null,selectedModels:new Set}},computed:{chatStore(){return Pinia.useChatStore()},providerIds(){return Object.keys(this.registry).sort()},filteredProviderIds(){let e=this.providerFilter.trim().toLowerCase();return e?this.providerIds.filter(t=>t.toLowerCase().includes(e)||(this.providerName(t)||"").toLowerCase().includes(e)):this.providerIds},selectedProviderModels(){let e=this.registry[this.selectedProviderId];return!e||typeof e.models!="object"?[]:Object.keys(e.models).sort()},filteredModelIds(){let e=this.modelFilter.trim().toLowerCase(),t=this.selectedProviderModels;return e?t.filter(s=>s.toLowerCase().includes(e)):t},fetchedAtLabel(){if(!this.fetchedAt)return null;let e=Math.max(0,Math.floor((Date.now()-this.fetchedAt)/6e4));return this.$t("settings.llm.preset.fetchedAt",{minutes:e})}},async mounted(){await this.load(!1)},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,onOverlayClick(e){Ze(e)&&this.$emit("close")},async load(e){this.loading=!0,this.error=null;try{let t=await this.chatStore.loadModelsDevRegistry({forceRefresh:e});this.registry=t?.registry||{},this.fetchedAt=t?.fetchedAt||0,t?.error&&(this.error=t.error)}catch(t){this.error=t?.message||String(t)}finally{this.loading=!1}},refresh(){this.load(!0)},providerName(e){return this.registry[e]?.name||e},providerModelCount(e){let t=this.registry[e]?.models;return t&&typeof t=="object"?Object.keys(t).length:0},selectProvider(e){this.selectedProviderId!==e&&(this.selectedProviderId=e,this.selectedModels=new Set,this.modelFilter="")},toggleModel(e){let t=new Set(this.selectedModels);t.has(e)?t.delete(e):t.add(e),this.selectedModels=t},selectAll(){this.selectedModels=new Set(this.filteredModelIds)},selectNone(){this.selectedModels=new Set},confirm(){if(!this.selectedProviderId||this.selectedModels.size===0)return;let e=this.registry[this.selectedProviderId]||{},t=Array.from(this.selectedModels).map(s=>{let n=
|
|
5463
|
+
`,data(){return{loading:!1,error:null,registry:{},fetchedAt:0,providerFilter:"",modelFilter:"",selectedProviderId:null,selectedModels:new Set}},computed:{chatStore(){return Pinia.useChatStore()},providerIds(){return Object.keys(this.registry).sort()},filteredProviderIds(){let e=this.providerFilter.trim().toLowerCase();return e?this.providerIds.filter(t=>t.toLowerCase().includes(e)||(this.providerName(t)||"").toLowerCase().includes(e)):this.providerIds},selectedProviderModels(){let e=this.registry[this.selectedProviderId];return!e||typeof e.models!="object"?[]:Object.keys(e.models).sort()},filteredModelIds(){let e=this.modelFilter.trim().toLowerCase(),t=this.selectedProviderModels;return e?t.filter(s=>s.toLowerCase().includes(e)):t},fetchedAtLabel(){if(!this.fetchedAt)return null;let e=Math.max(0,Math.floor((Date.now()-this.fetchedAt)/6e4));return this.$t("settings.llm.preset.fetchedAt",{minutes:e})}},async mounted(){await this.load(!1)},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,onOverlayClick(e){Ze(e)&&this.$emit("close")},async load(e){this.loading=!0,this.error=null;try{let t=await this.chatStore.loadModelsDevRegistry({forceRefresh:e});this.registry=t?.registry||{},this.fetchedAt=t?.fetchedAt||0,t?.error&&(this.error=t.error)}catch(t){this.error=t?.message||String(t)}finally{this.loading=!1}},refresh(){this.load(!0)},providerName(e){return this.registry[e]?.name||e},providerModelCount(e){let t=this.registry[e]?.models;return t&&typeof t=="object"?Object.keys(t).length:0},selectProvider(e){this.selectedProviderId!==e&&(this.selectedProviderId=e,this.selectedModels=new Set,this.modelFilter="")},toggleModel(e){let t=new Set(this.selectedModels);t.has(e)?t.delete(e):t.add(e),this.selectedModels=t},selectAll(){this.selectedModels=new Set(this.filteredModelIds)},selectNone(){this.selectedModels=new Set},confirm(){if(!this.selectedProviderId||this.selectedModels.size===0)return;let e=this.registry[this.selectedProviderId]||{},t=Array.from(this.selectedModels).map(s=>{let n=by(s);return n?{id:s,protocol:n}:s});this.$emit("pick",{name:this.selectedProviderId,baseUrl:e.api||"",protocol:"",models:t})}}}});var $i,ol=F(()=>{tg();ng();$i={name:"LlmTab",components:{ProviderPresetPicker:sg},props:{context:{type:String,default:"chat"}},emits:["message","saved"],template:`
|
|
5469
5464
|
<div class="llm-tab">
|
|
5470
5465
|
<!-- No agent selected -->
|
|
5471
5466
|
<div v-if="!effectiveAgentId" class="sp-desc">
|
|
@@ -5668,7 +5663,7 @@ ${String(e||"").trim()}
|
|
|
5668
5663
|
</div>
|
|
5669
5664
|
</div>
|
|
5670
5665
|
</div>
|
|
5671
|
-
`,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null,saveRefreshWarning:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let r of n)t.push(`${s.name}/${r}`)}return t}},watch:{effectiveAgentId:{handler(e,t){e!==t&&(this.cancelPendingDiscovery(),this.cancelPendingSave(),this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,this.loadError=null,this.localProviders=[],this.providerModelsText=[],this.localPrimaryModel=null,this.localFastModel=null,this.isDirty=!1,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null,this.saveRefreshWarning=null),e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.cancelPendingDiscovery(),this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this._pendingDiscovery={agentId:e,requestId:t},this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(!(this._pendingDiscovery?.agentId!==e||this._pendingDiscovery?.requestId!==t||this.effectiveAgentId!==e)){if(this._pendingDiscovery=null,this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null}},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),r=i=>{this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,s(i)};this._resolvePendingDiscovery=r,this._discoveryTimer=setInterval(()=>{let i=this.chatStore.llmModelDiscovery?.[e];if(i?.requestId===t){r(i);return}Date.now()-n>1e4&&r({error:"Timed out while refreshing provider models."})},100)})},cancelPendingDiscovery(){let e=this._resolvePendingDiscovery;this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,this._pendingDiscovery=null,this.discoveringModels=!1,e&&e({cancelled:!0})},cancelPendingSave(){this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this._saveUnwatch&&(this._saveUnwatch(),this._saveUnwatch=null),this._pendingSave=null,this.saving=!1},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(o=>o?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let r=new Set(this.parseModelsFromProvider(t).map(o=>`${t.name}/${o}`)),i=r.values().next().value||null;i&&!r.has(this.localPrimaryModel)&&(this.localPrimaryModel=i),i&&this.localFastModel?.startsWith(`${t.name}/`)&&!r.has(this.localFastModel)&&(this.localFastModel=i),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(i=>(i.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let r=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:r}),this.providerModelsText.push(r.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],r=new Map;for(let i of n){let o=this._modelId(i);o&&r.set(o,i)}this.editableProviders[e].models=s.split(/[\n,]+/).map(i=>i.trim()).filter(i=>i).map(i=>r.has(i)?r.get(i):i),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(r=>r).length===0&&t!==s){let r=this._getModelPresets(t);r.length>0&&(this.editableProviders[e].models=[...r],this.providerModelsText[e]=r.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return il[e]||il.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0,this.saveRefreshWarning=null;let s={providers:this.editableProviders.filter(r=>r.name&&(this.isManagedProvider(r)||r.baseUrl)).map(r=>{if(this.isManagedProvider(r))return{name:r.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:r.managed||"github-copilot",models:(r.models||[]).filter(o=>this._modelId(o))};let i={type:r.type||"api-key",name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey||"",githubToken:r.githubToken||"",models:(r.models||[]).filter(o=>this._modelId(o))};return r.protocol&&r.protocol!=="openai"&&(i.protocol=r.protocol),r.credentialProvider&&(i.credentialProvider=r.credentialProvider,i.apiKey=""),i}),primaryModel:this.localPrimaryModel||null};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null);let n=`llm-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.cancelPendingSave(),this.saving=!0,this._pendingSave={agentId:e,requestId:n},this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,requestId:n,config:s}),this._saveTimeout=setTimeout(()=>{this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n||(this.cancelPendingSave(),this.$emit("message",this.$t("settings.llm.saveFailed"),!0))},1e4),this._saveUnwatch=this.$watch("currentConfig",r=>{if(!(!r?.loaded||r.requestId!==n||this.effectiveAgentId!==e||this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n)){if(this.cancelPendingSave(),r.error){this.$emit("message",r.error,!0);return}this.isDirty=!1,this.saveRefreshWarning=r.statusRefreshError?this.$t("settings.llm.savedRefreshWarning",{error:r.statusRefreshError}):null,this.$emit("message",this.saveRefreshWarning||this.$t("settings.llm.saved"),!!r.statusRefreshError),this.$emit("saved",{warning:this.saveRefreshWarning})}},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this.cancelPendingDiscovery(),this.cancelPendingSave()}}});function ks(e){let t=(Number(e?.actionRunOpenGeneration)||0)+1;return e&&(e.actionRunOpenGeneration=t),t}var Vi,al=F(()=>{Zf();eg();ol();Ci();tl();ei();Ko();sl();vs();Vi={name:"WorkCenterPage",components:{WorkCenterActionDetail:Xf,WorkCenterSettingsModal:Jf,LlmTab:$i,ModernSelect:Js},mixins:[Kf],data(){return{selectedId:null,selectedActionId:null,narrowPane:"items",mobileWorkItemPane:"conversation",contentStack:[{type:"action-list"}],staleComposerTarget:null,composerTargetValue:"coordinator",actionDetailTab:"messages",actionInputRequestGeneration:0,actionRunOpenGeneration:0,workItemMessage:"",workItemMessageAttachments:[],workItemMessageAttachmentsUploading:!1,workItemMessageSending:!1,workItemMessageError:"",workItemComposerGeneration:0,preserveComposerOnEnvelopeClear:!1,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,createGeneration:0,llmConfigOpen:!1,search:"",boardVpId:"",boardWorkItemType:"",boardUpdatedRange:"week",mobileBoardLane:"active",deletingWorkItemIds:{},deleteWorkItemError:"",boardQueryTimer:null,expandedActions:{},actionsExpanded:!1,workDirTouched:!1,startTouched:!1,createAttachments:[],attachmentsUploading:!1,previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},chat(){return this.store},agentId(){return this.store.workCenterAgentId||this.store.currentAgent},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},workCenterAgentOptions(){return this.onlineAgents.map(e=>({value:e.id,label:e.name||e.id}))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},boardNextCursor(){return this.store.workCenterListPageByAgent[this.agentId]?.nextCursor||null},boardLoadingMore(){return!!this.store.workCenterListMoreLoadingByAgent[this.agentId]},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){return this.runtime?.workItemAttachments===!0},canonicalMessageWireSupported(){return this.agents.find(e=>e?.id===this.agentId)?.capabilities?.includes("work_center_message_v2")===!0},createDefaultWorkDir(){return this.settings?.defaultWorkDir||this.runtime?.defaultWorkDir||""},createDefaultStart(){return this.settings?.startImmediately!==!1},folderPickerAgentId(){return this.agentId||""},defaultWorkDir(){return this.createDefaultWorkDir},items(){return this.store.workCenterItemsByAgent[this.agentId]||[]},loading(){return!!this.store.workCenterLoadingByAgent[this.agentId]},loaded(){return!!this.store.workCenterLoadedByAgent[this.agentId]},error(){return this.store.workCenterErrorByAgent[this.agentId]||null},detail(){return this.store.workCenterDetailByAgent[this.agentId]||null},selected(){return this.detail?.id===this.selectedId?this.detail:this.items.find(e=>e.id===this.selectedId)||null},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},contentRef(){return this.contentStack[this.contentStack.length-1]||{type:"action-list"}},contentIsActionList(){return this.contentRef.type==="action-list"},composerTargetIsCoordinator(){return this.composerTargetValue==="coordinator"},composerTargetAction(){if(!this.composerTargetValue.startsWith("action:"))return null;let[,e,t]=this.composerTargetValue.split(":"),s=Number(t);return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(r=>r.id===e&&Number(r.generation)===s)||null},composerTargetIsStale(){return this.composerTargetValue!=="coordinator"&&!this.composerTargetAction},composerTargetOptions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[];return[{value:"coordinator",label:this.tr("workCenter.coordinator","Coordinator"),disabled:!1},...e.map(t=>({value:`action:${t.id}:${t.generation}`,label:this.$t("workCenter.composerTargetAction",{sequence:this.actionSequence(t),name:t.brief?.objective||this.actionLabel(t.type)}),disabled:!this.canMessageAction(t)}))]},composerTargetLabel(){return this.composerTargetAction?this.composerTargetAction.brief?.objective||this.actionLabel(this.composerTargetAction.type):this.tr("workCenter.coordinator","Coordinator")},composerPlaceholder(){return this.composerTargetAction?this.$t("workCenter.actionChatPlaceholder",{name:this.composerTargetLabel}):this.tr("workCenter.conversationPlaceholder","Message about this work item")},composerTargetUnavailable(){return this.coordinatorReadOnly?!0:this.composerTargetIsCoordinator?this.coordinatorThinking:this.composerTargetAction?!this.canMessageAction(this.composerTargetAction):!0},composerCanSend(){return!this.workItemMessageSending&&!this.workItemMessageAttachmentsUploading&&!this.composerTargetUnavailable&&(!!this.workItemMessage.trim()||this.workItemMessageAttachments.length>0)},pendingMessageEnvelope(){return this.selected?.id?this.store.loadWorkCenterMessageEnvelope(this.agentId,this.selected.id):null},composerDraftLocked(){return!!this.pendingMessageEnvelope&&!this.composerTargetIsStale},pendingEnvelopeHasAttachments(){return Array.isArray(this.pendingMessageEnvelope?.attachments)&&this.pendingMessageEnvelope.attachments.length>0},pendingEnvelopeAttachmentRecovery(){return this.composerDraftLocked&&this.pendingEnvelopeHasAttachments},actionRequestKey(){return this.selected?.id&&this.selectedAction?.id?Dn(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},actionMessageKey(){return this.selected?.id&&this.selectedAction?.id?qs(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},workItemComposerScope(){return this.selected?.id?`${this.agentId}:${this.selected.id}:${this.workItemComposerGeneration}`:""},coordinatorThinking(){return(this.selected?.messages||[]).some(e=>e?.role==="assistant"&&e.status==="thinking")},coordinatorReadOnly(){return["done","cancelled"].includes(this.selected?.status)},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=(Array.isArray(this.selectedAction?.thread)?this.selectedAction.thread:[]).flatMap(o=>Array.isArray(o?.messages)?o.messages:[]),s=this.store.workCenterActionMessages[this.actionMessageKey]?.messages||[],n=En(t,s,e),r=this.selectedAction?.liveMessage,i=r&&n.some(o=>o.role==="assistant"&&o.runId!=null&&o.runId===r.runId&&(r.status==="running"?o.text===r.text:o.status!=="running"));return En(n,i?null:r)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionMessageKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionMessageKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionMessageKey]||""},orderedActions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[],t={running:0,waiting:1,failed:2,ready:3,completed:4,done:4,superseded:5,cancelled:6};return e.map((s,n)=>({action:s,index:n})).sort((s,n)=>{let r=t[s.action?.status]??7,i=t[n.action?.status]??7;if(r!==i)return r-i;let o=Number(s.action?.sequence),a=Number(n.action?.sequence);return Number.isFinite(o)&&Number.isFinite(a)&&o!==a?o-a:s.index-n.index}).map(s=>s.action)},actionRequests(){return this.store.workCenterActionRequests[this.actionRequestKey]||[]},actionRequestDetails(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,this.store.workCenterActionRequestDetails[`${this.actionRequestKey}:${t}`]||null]})):{}},actionRequestDetailsLoading(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,!!this.store.workCenterActionRequestDetailsLoading[`${this.actionRequestKey}:${t}`]]})):{}},actionRequestDetailsError(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,this.store.workCenterActionRequestDetailsError[`${this.actionRequestKey}:${t}`]||""]})):{}},actionRequestsLoading(){return!!this.store.workCenterActionRequestsLoading[this.actionRequestKey]},actionRequestsError(){return this.store.workCenterActionRequestsError[this.actionRequestKey]||""},boardLanes(){return[{id:"active",title:this.tr("workCenter.board.active","Active")},{id:"needs_attention",title:this.tr("workCenter.board.needsAttention","Needs attention")},{id:"closed",title:this.tr("workCenter.board.closed","Closed")}].map(e=>({...e,items:this.items.filter(t=>t.boardLane===e.id)}))},boardExecutorOptions(){let e=new Map;for(let t of this.items)for(let s of Array.isArray(t.executors)?t.executors:[])s?.id&&e.set(s.id,s.name||s.id);return[...e.entries()].map(([t,s])=>({id:t,name:s}))},boardTypeOptions(){return[...new Set(this.items.map(e=>e.workItemType).filter(Boolean))].sort()},emptyState(){return{title:this.search.trim()?this.tr("workCenter.noMatchesTitle","No matching work items"):this.tr("workCenter.emptyTitle","No work items yet"),body:this.search.trim()?this.tr("workCenter.noMatchesBody","Try a different search or filter."):this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!this.search.trim()}}},watch:{agentId:{immediate:!0,handler(e,t){ks(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.saving=!1,this.selectedId=null,this.selectedActionId=null,this.resetWorkItemComposer?.(),this.resetContentStack?.(),this.composerTargetValue="coordinator",this.narrowPane="items",this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),e&&((typeof this.boardFilters=="function"?this.store.listWorkItems(e,this.boardFilters()):this.store.listWorkItems(e)).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},search(){this.scheduleBoardQuery()},boardVpId(){this.scheduleBoardQuery()},boardWorkItemType(){this.scheduleBoardQuery()},boardUpdatedRange(){this.scheduleBoardQuery()},"detail.coordinatorRevision"(){this.$nextTick(()=>{let e=this.$el?.querySelector?.(".work-center-item-message-list");e&&(e.scrollTop=e.scrollHeight)})},pendingMessageEnvelope(e,t){if(!(!t||e||t.workItemId!==this.selectedId)){if(this.preserveComposerOnEnvelopeClear){this.preserveComposerOnEnvelopeClear=!1,this.workItemMessageError="",this.workItemMessageSending=!1;return}this.workItemMessage="",this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1,this.$nextTick(()=>this.resizeWorkItemComposer(this.$refs.workItemComposerInput,!0))}},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];this.selectedActionId&&!t.some(s=>s.id===this.selectedActionId)&&(ks(this),this.selectedActionId=null,this.resetContentStack(),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.staleComposerTarget=this.composerTargetValue:this.staleComposerTarget=null}}},beforeUnmount(){ks(this),this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),window.removeEventListener("popstate",this.restoreWorkCenterUrl)},mounted(){window.addEventListener("popstate",this.restoreWorkCenterUrl),this.restoreWorkCenterUrl();let e=this.store.workCenterCreateDraft;e&&(this.form={requirement:e.requirement||e.goal||e.title||"",workDir:e.workDir||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,closeLlmConfigFromOverlay(e){Ze(e)&&(this.llmConfigOpen=!1)},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},selectWorkCenterAgent(e){!e||e===this.agentId||this.store.enterWorkCenter(e)},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},actionSequence(e){let t=Number(e?.sequence);if(Number.isFinite(t)&&t>0)return t;let n=(Array.isArray(this.selected?.actions)?this.selected.actions:[]).findIndex(r=>r?.id===e?.id);return n>=0?n+1:1},actionBreadcrumbDescription(e){return String(e?.brief?.objective||e?.objective||this.actionContentSummary(e)||"").trim().replace(/\s+/g," ")||this.tr("workCenter.untitledAction","Untitled Action")},itemActionProgress(e){let t=Math.max(0,Number(e?.actionCount)||0),s=Math.min(t,Math.max(0,Number(e?.completedActionCount)||0));return this.$t("workCenter.actionProgress",{completed:s,total:t})},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},resizeWorkItemComposer(e,t=!1){if(!e)return;e.style.height="auto";let s=t?24:Math.min(e.scrollHeight,144);e.style.height=`${s}px`,e.style.overflowY=e.scrollHeight>144?"auto":"hidden"},onWorkItemMessageInput(e){this.workItemMessage=e.target.value,this.saveComposerDraft(),this.resizeWorkItemComposer(e.target,!e.target.value)},onWorkItemMessageKeydown(e){e.key!=="Enter"||e.shiftKey||e.isComposing||(e.preventDefault(),this.sendSelectedWorkItemMessage())},boardFilters(){let e=Date.now(),t=this.boardUpdatedRange==="day"?e-1440*60*1e3:this.boardUpdatedRange==="week"?e-10080*60*1e3:this.boardUpdatedRange==="month"?e-720*60*60*1e3:null;return{keyword:this.search.trim(),vpId:this.boardVpId,workItemType:this.boardWorkItemType,updatedFrom:t,limit:200}},scheduleBoardQuery(){this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),this.boardQueryTimer=setTimeout(()=>{this.boardQueryTimer=null,this.agentId&&this.refresh()},180)},refresh(){return this.store.listWorkItems(this.agentId,this.boardFilters()).catch(()=>{})},loadMoreBoardItems(){return this.store.loadMoreWorkItems(this.agentId).catch(()=>{})},boardAction(e){return e.attentionAction||e.activeAction||e.currentAction||null},boardActionCountLabel(e){let t=e.actionCounts||{},s=[];for(let n of["running","failed","waiting","ready"])Number(t[n])>0&&s.push(`${t[n]} ${this.statusLabel(n)}`);return s.join(" \xB7 ")||this.itemActionProgress(e)},boardExecutorLabel(e){let t=Array.isArray(e.executors)?e.executors:[];if(t.length>0)return t.map(n=>n.name||n.id).join(", ");let s=this.boardAction(e);return s?.assignedVp?.name||s?.assignedVp?.id||this.tr("workCenter.assignment.planned","Planned assignment")},sameContentRef(e,t){return e?.type===t?.type&&e?.actionId===t?.actionId&&e?.runId===t?.runId&&e?.resourceId===t?.resourceId},resetContentStack(e=[{type:"action-list"}]){let t=Array.isArray(e)?e:[e],s=t[0]?.type==="action-list"?t:[{type:"action-list"},...t];this.contentStack=s.length>0?s:[{type:"action-list"}];let n=[...this.contentStack].reverse().find(r=>r.type==="action");this.selectedActionId=this.contentRef.actionId||n?.actionId||null},pushContentRef(e,{replace:t=!1,syncUrl:s=!0}={}){let n=this.contentRef;if(this.sameContentRef(n,e)){this.mobileWorkItemPane="content";return}this.contentStack=e.type==="action-list"?[{type:"action-list"}]:[...this.contentStack,e],this.selectedActionId=e.actionId||this.selectedActionId,this.mobileWorkItemPane="content",s&&this.syncWorkCenterUrl(t)},popContentRef(){if(this.contentStack.length<=1)return;this.contentStack=this.contentStack.slice(0,-1);let e=[...this.contentStack].reverse().find(t=>t.type==="action");this.selectedActionId=e?.actionId||null,this.mobileWorkItemPane="content",this.syncWorkCenterUrl()},contentRefParam(e){return e.type==="action"&&e.actionId?`action:${e.actionId}`:e.type==="run"&&e.actionId&&e.runId?`run:${e.actionId}:${e.runId}`:e.type==="attachment"&&e.resourceId?`attachment:${e.actionId||"-"}:${e.resourceId}`:"action-list"},contentStackParam(){return this.contentStack.map(e=>this.contentRefParam(e)).join("/")},parseContentRef(e){let t=String(e||"");if(t==="action-list")return{type:"action-list"};if(t.startsWith("action:"))return{type:"action",actionId:t.slice(7)};if(t.startsWith("run:")){let[,s,n]=t.split(":");return{type:"run",actionId:s,runId:n}}if(t.startsWith("attachment:")){let[,s,n]=t.split(":");return{type:"attachment",actionId:s==="-"?null:s,resourceId:n}}return{type:"action-list"}},parseContentStack(e){let t=String(e||"").split("/").filter(Boolean).map(s=>this.parseContentRef(s));return t.length>0?t:[{type:"action-list"}]},syncWorkCenterUrl(e=!1){let t=new URL(window.location.href);this.selectedId?(t.searchParams.set("workAgentId",this.agentId||""),t.searchParams.set("workItemId",this.selectedId),t.searchParams.set("workContent",this.contentStackParam())):(t.searchParams.delete("workAgentId"),t.searchParams.delete("workItemId"),t.searchParams.delete("workContent"));let s=`${t.pathname}${t.search}${t.hash}`;if(`${window.location.pathname}${window.location.search}${window.location.hash}`===s)return;let n={...window.history.state,workCenter:!!this.selectedId,workCenterContent:!!this.selectedId&&this.contentStack.length>1};window.history[e?"replaceState":"pushState"](n,"",s)},async restoreWorkCenterUrl(){let e=new URLSearchParams(window.location.search),t=e.get("workAgentId"),s=e.get("workItemId");if(!s||t&&t!==this.agentId){this.selectedId&&this.showItemsPane({syncUrl:!1});return}let n=this.parseContentStack(e.get("workContent")),r=n.at(-1);if(this.selectedId!==s||this.detail?.id!==s){this.openWorkItem(s,{syncUrl:!1,contentRefs:n}),this.detailLoading=!0;try{await this.store.getWorkItem(s,this.agentId)}catch(o){this.selectedId===s&&(this.detailError=o?.message||String(o))}finally{this.selectedId===s&&(this.detailLoading=!1)}}let i=r.actionId||[...n].reverse().find(o=>o.type==="action")?.actionId;if(i&&!this.selected?.actions?.some(o=>o.id===i)){this.resetContentStack(),this.syncWorkCenterUrl(!0);return}this.resetContentStack(n),this.narrowPane="work-item",this.mobileWorkItemPane=r.type==="action-list"?"conversation":"content",i&&this.loadLatestActionMessages(this.selectedAction)},resetWorkItemComposer(){this.workItemComposerGeneration+=1,this.workItemMessage="",this.workItemMessageAttachments=[],this.workItemMessageAttachmentsUploading=!1,this.workItemMessageError="",this.workItemMessageSending=!1},draftTarget(){let e=this.composerTargetAction;return e?{kind:"action",actionId:e.id,generation:Number(e.generation)}:this.composerTargetValue==="coordinator"?{kind:"coordinator"}:(()=>{let[,t="",s="0"]=this.composerTargetValue.split(":");return{kind:"action",actionId:t,generation:Number(s)||0}})()},targetValue(e){return typeof e=="string"&&e.startsWith("action:")?e:e?.kind==="action"?`action:${e.actionId}:${e.generation}`:"coordinator"},saveComposerDraft(){!this.selectedId||!this.agentId||this.store.saveWorkCenterComposerDraft(this.agentId,this.selectedId,{text:this.workItemMessage,attachments:[...this.workItemMessageAttachments],target:this.draftTarget(),error:this.workItemMessageError})},restoreComposerDraft(e){let s=this.store.loadWorkCenterMessageEnvelope(this.agentId,e)||this.store.loadWorkCenterComposerDraft(this.agentId,e);this.workItemMessage=s?.text||"",this.workItemMessageAttachments=[...s?.attachments||[]],this.composerTargetValue=this.targetValue(s?.target),this.workItemMessageError=s?.error||"",this.staleComposerTarget=null,this.workItemMessageSending=!1,this.workItemMessageAttachmentsUploading=!1,this.workItemComposerGeneration+=1},openWorkItem(e,{syncUrl:t=!0,contentRefs:s=[{type:"action-list"}]}={}){this.saveComposerDraft(),ks(this),this.selectedId=e,this.narrowPane="work-item",this.mobileWorkItemPane="conversation",this.resetContentStack(s),this.restoreComposerDraft(e),this.expandedActions={},this.actionsExpanded=!1,this.detailError="",this.detailLoading=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&this.syncWorkCenterUrl()},async selectItem(e){this.openWorkItem(e.id),this.detailLoading=!0;try{await this.store.getWorkItem(e.id,this.agentId)}catch(t){this.selectedId===e.id&&(this.detailError=t?.message||String(t))}finally{this.selectedId===e.id&&(this.detailLoading=!1)}},selectAction(e){this.selectedActionId!==e.id&&(ks(this),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.pushContentRef({type:"action",actionId:e.id}),this.loadLatestActionMessages(e)},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=qs(this.agentId,this.selected.id,e.id,e.generation);return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,e.generation,null,this.agentId).catch(()=>null)},showItemsPane({syncUrl:e=!0}={}){this.saveComposerDraft(),this.narrowPane="items",this.selectedId=null,this.resetContentStack(),this.composerTargetValue="coordinator",this.resetWorkItemComposer(),e&&this.syncWorkCenterUrl()},showActionsPane(){this.mobileWorkItemPane="content",this.contentIsActionList||this.popContentRef()},canMessageAction(e){return!e||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(e.status)&&e.admissionStatus!=="blocked"},chooseCoordinatorTarget(){this.pendingMessageEnvelope&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.composerTargetValue="coordinator",this.staleComposerTarget=null,this.saveComposerDraft()},onComposerTargetChange(){this.pendingMessageEnvelope&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.staleComposerTarget=this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.composerTargetValue:null,this.saveComposerDraft()},setComposerTargetForAction(e=this.selectedAction){if(!e?.id||!this.canMessageAction(e))return;let t=`action:${e.id}:${e.generation}`;this.pendingMessageEnvelope&&this.composerTargetValue!==t&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.composerTargetValue=t,this.staleComposerTarget=null,this.saveComposerDraft(),this.mobileWorkItemPane="conversation",this.$nextTick(()=>this.$refs.workItemComposerInput?.focus())},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},async refreshActionRequests(){return!this.selected?.id||!this.selectedAction?.id?[]:this.store.loadWorkItemActionRequests(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.agentId).catch(()=>[])},loadActionRequest(e){return!this.selected?.id||!this.selectedAction?.id||!e?.id?null:this.store.loadWorkItemActionRequest(this.selected.id,this.selectedAction.id,this.selectedAction.generation,e.runId,e.id,this.agentId).catch(()=>null)},async openActionRun(e,t){let s=ks(this),n={agentId:this.agentId,workItemId:this.selected?.id,actionId:this.selectedAction?.id,generation:this.selectedAction?.generation,runId:e?.id},r=()=>this.actionRunOpenGeneration===s&&this.agentId===n.agentId&&this.selected?.id===n.workItemId&&this.selectedAction?.id===n.actionId&&this.selectedAction?.generation===n.generation;if(!n.workItemId||!n.actionId||!n.runId)return t?.(null);let i=await this.store.loadWorkItemActionRequests(n.workItemId,n.actionId,n.generation,n.agentId).catch(()=>[]);if(!r())return t?.(null);let o=i.find(l=>l.runId===n.runId)||null;return!o||!await this.store.loadWorkItemActionRequest(n.workItemId,n.actionId,n.generation,o.runId,o.id,n.agentId).catch(()=>null)||!r()?t?.(null):(this.pushContentRef({type:"run",actionId:n.actionId,runId:n.runId}),t?.(o))},actionHasDetail(e){return!!e?.brief||Array.isArray(e?.messages)&&e.messages.length>0||!!String(e?.response||"").trim()||!!String(e?.failureReason||"").trim()},actionExpanded(e){return!!this.expandedActions[e?.id]},toggleAction(e){this.actionHasDetail(e)&&(this.expandedActions={...this.expandedActions,[e.id]:!this.expandedActions[e.id]})},actionResponseText(e){return String(e?.response||"").trim()},actionExecutor(e){return e?.assignedVp?.name||e?.assignedVp?.id||e?.requiredRole||e?.assignmentPolicy?.fixedVpId||e?.assignmentPolicy?.capability||this.tr("workCenter.assignment.auto","Auto")},actionContentSummary(e){return String(e?.contentSummary||e?.response||e?.brief?.objective||"").trim()},executionStats(e){return e?.executionStats||{}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},resetCreateExecutionContext(e){let t=this.workDirTouched||this.startTouched,s=this.store.workCenterCreateDraft;s&&(this.store.workCenterCreateDraft={sourceAgentId:e||null,requirement:s.requirement||s.goal||s.title||"",workDir:"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateWorkDirInput(){this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},async onCreateAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=Math.max(0,10-this.createAttachments.length),n=t.slice(0,s);if(n.length!==0){this.attachmentsUploading=!0;try{let r=new FormData;for(let d of n)r.append("files",d,d.name||"attachment");let i=Pinia.useAuthStore(),o=i.getActiveToken?.()||i.token||null,a=o?{Authorization:`Bearer ${o}`}:{},l=await fetch("/api/upload",{method:"POST",headers:a,body:r});if(!l.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let c=await l.json();this.createAttachments=[...this.createAttachments,...Array.isArray(c.files)?c.files:[]].slice(0,10)}finally{this.attachmentsUploading=!1}}},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},discardPendingMessageEnvelope(){if(!(!this.selectedId||!this.pendingMessageEnvelope)){if(this.actionInputRequestGeneration=(Number(this.actionInputRequestGeneration)||0)+1,this.preserveComposerOnEnvelopeClear=!0,!this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId)){this.preserveComposerOnEnvelopeClear=!1;return}this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1,this.saveComposerDraft()}},async onWorkItemMessageAttachmentInput(e){if(!this.workItemAttachmentsSupported){e.target.value="",this.workItemMessageError=this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments.");return}let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=this.workItemComposerScope;if(!s)return;let n=this.pendingEnvelopeAttachmentRecovery,r=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,i=Math.max(0,10-r-(n?0:this.workItemMessageAttachments.length)),o=t.slice(0,i);if(o.length!==0){this.workItemMessageAttachmentsUploading=!0,this.workItemMessageError="";try{let a=new FormData;for(let g of o)a.append("files",g,g.name||"attachment");let l=Pinia.useAuthStore(),c=l.getActiveToken?.()||l.token||null,d=c?{Authorization:`Bearer ${c}`}:{},u=await fetch("/api/upload",{method:"POST",headers:d,body:a});if(!u.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let f=await u.json();if(this.workItemComposerScope!==s)return;let p=(Array.isArray(f.files)?f.files:[]).slice(0,Math.max(0,10-r));if(n){let g=this.store.replaceWorkCenterMessageEnvelopeAttachments(this.agentId,this.selectedId,p);if(!g)throw new Error(this.tr("workCenter.pendingEnvelopeChanged","The pending request changed; reopen this Work Item and try again."));this.workItemMessageAttachments=[...g.attachments],this.workItemMessageError=""}else this.workItemMessageAttachments=[...this.workItemMessageAttachments,...p].slice(0,Math.max(0,10-r)),this.saveComposerDraft()}catch(a){this.workItemComposerScope===s&&(this.workItemMessageError=a?.message||String(a))}finally{this.workItemComposerScope===s&&(this.workItemMessageAttachmentsUploading=!1)}}},removeWorkItemMessageAttachment(e){this.workItemMessageAttachments=this.workItemMessageAttachments.filter((t,s)=>s!==e),this.saveComposerDraft()},async previewAttachment(e,t=null){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;this.pushContentRef({type:"attachment",actionId:this.selectedActionId||null,resourceId:e.id});let s=this.agentId,n=this.selected.id,r=this.selectedActionId||"",i=`${s}:${n}:${r}`,o=(Number(this.attachmentPreviewGeneration)||0)+1;this.attachmentPreviewGeneration=o;let a=()=>this.attachmentPreviewGeneration===o&&`${this.agentId}:${this.selected?.id||""}:${this.selectedActionId||""}`===i,l=e.isImage?null:window.open("","_blank");if(!e.isImage&&!l){this.attachmentPreviewError=this.tr("workCenter.attachmentOpenBlocked","The browser blocked the attachment window. Allow pop-ups and try again.");return}l&&(l.opener=null),this.previewingAttachmentId=e.id,this.attachmentPreviewError="";try{let c=await this.store.previewWorkItemAttachment(n,e.id,s);if(!a()){l?.close();return}c?.preview&&c.attachment?.isImage?js(c.preview,{alt:e.name||this.tr("workCenter.previewAttachment","Open attachment"),closeLabel:this.tr("common.close","Close"),trigger:t}):c?.preview&&l?l.location.replace(c.preview):l?.close()}catch(c){l?.close(),a()&&(this.attachmentPreviewError=c?.message||this.tr("workCenter.attachmentPreviewFailed","Could not open the attachment. Try again."))}finally{a()&&(this.previewingAttachmentId=null)}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.applyCreateDefaults()},closeCreate(){this.saving||(this.closeFolderPicker(),this.createOpen=!1,this.store.workCenterCreateDraft=null)},onLlmConfigSaved(){let e=this.agentId;if(e)return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},async submitCreate(){let e=String(this.form.requirement||this.form.goal||this.form.title||"").trim();if(!e||!this.form.workDir.trim())return;let t=this.agentId,s=(Number(this.createGeneration)||0)+1;this.createGeneration=s,this.saving=!0;try{let n=this.store.workCenterCreateDraft,r=n?.sourceAgentId===t,i=await this.store.createWorkItem({requirement:e,title:e,goal:e,acceptanceCriteria:[],workItemType:"auto",workDir:this.form.workDir.trim(),origin:r&&n.origin||null,linkedSessionIds:r?n.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(o=>({fileId:o.fileId,name:o.name,mimeType:o.mimeType,size:o.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.start},t);if(this.agentId!==t||this.createGeneration!==s)return;this.openWorkItem(i.id),this.form={requirement:"",workDir:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.createOpen=!1}finally{this.agentId===t&&this.createGeneration===s&&(this.saving=!1)}},async startSelected(){this.selected&&await this.store.startWorkItem(this.selected.id,this.agentId)},async sendSelectedWorkItemMessage(){if(!this.selected||!this.composerCanSend)return;let e=this.workItemComposerScope,t=this.composerTargetValue,s=this.composerTargetAction;if(!this.composerTargetIsCoordinator&&!s)return;let n=this.selected.id,r=this.selected.revision,i=this.workItemMessage.trim(),o=this.workItemMessageAttachments.map(l=>({fileId:l.fileId,name:l.name,mimeType:l.mimeType,size:l.size})),a=(Number(this.actionInputRequestGeneration)||0)+1;this.actionInputRequestGeneration=a,this.workItemMessageSending=!0,this.workItemMessageError="",this.saveComposerDraft();try{let l={planRevision:this.selected.planRevision,ledgerRevision:this.selected.ledgerRevision,coordinatorRevision:this.selected.coordinatorRevision};this.canonicalMessageWireSupported?await this.store.postWorkItemMessage(n,i,s?{kind:"action",actionId:s.id,generation:s.generation}:{kind:"coordinator"},r,o,this.agentId,l):s?await this.store.sendWorkItemActionInput(n,i,s.id,r,s.generation,o,this.agentId):await this.store.sendWorkItemMessage(n,i,r,o,this.agentId,l),this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&this.composerTargetValue===t&&this.workItemMessage.trim()===i&&!this.store.loadWorkCenterMessageEnvelope(this.agentId,n)&&(this.workItemMessage="",this.workItemMessageAttachments=[],this.store.removeWorkCenterComposerDraft(this.agentId,n),this.$nextTick(()=>this.resizeWorkItemComposer(this.$refs.workItemComposerInput,!0)))}catch(l){this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&(this.workItemMessageError=l?.message||String(l),this.saveComposerDraft())}finally{this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&(this.workItemMessageSending=!1)}},workItemCanDelete(e){return["done","cancelled","draft","needs_attention"].includes(e?.status)},workItemDeleting(e){return!!this.deletingWorkItemIds[e?.id]},async deleteWorkItem(e){if(!e||this.workItemDeleting(e))return;let t=this.tr("workCenter.deleteConfirm","Permanently delete this Work Item, its execution history, and attachments?");if(!(typeof confirm=="function"&&!confirm(t))){this.deleteWorkItemError="",this.deletingWorkItemIds={...this.deletingWorkItemIds,[e.id]:!0};try{let s=await this.store.deleteWorkItem(e.id,e.revision,this.agentId);s?.cleanupWarning&&(this.deleteWorkItemError=s.cleanupWarning),this.selectedId===e.id&&(ks(this),this.showItemsPane())}catch(s){this.deleteWorkItemError=s?.message||String(s)}finally{let s={...this.deletingWorkItemIds};delete s[e.id],this.deletingWorkItemIds=s}}},async cancelSelected(){if(!this.selected||["done","cancelled"].includes(this.selected.status))return;let e=this.tr("workCenter.cancelConfirm","Stop this work item and its unfinished Actions?");typeof confirm=="function"&&!confirm(e)||await this.store.cancelWorkItem(this.selected.id,this.agentId)},async resumeSelected(){!this.selected||this.selected.status!=="cancelled"||await this.store.resumeWorkItem(this.selected.id,this.selected.revision,this.agentId)}},template:`
|
|
5666
|
+
`,directives:{"click-outside":{mounted(e,t){e._clickOutside=s=>{e.contains(s.target)||t.value()},document.addEventListener("click",e._clickOutside)},unmounted(e){document.removeEventListener("click",e._clickOutside)}}},data(){return{loading:!1,loadError:null,localProviders:[],providerModelsText:[],localPrimaryModel:null,localFastModel:null,isDirty:!1,saving:!1,openDropdown:null,showApiKey:{},showPresetPicker:!1,discoveringModels:!1,modelDiscoveryWarning:null,modelDiscoveryError:null,saveRefreshWarning:null}},computed:{chatStore(){return Pinia.useChatStore()},effectiveAgentId(){return this.chatStore.currentAgent},agentOnline(){let e=this.effectiveAgentId;if(!e)return!1;if(this.context==="yeaft")return!0;let t=this.chatStore.agents.find(s=>s.id===e);return t?t.online:!1},currentConfig(){let e=this.effectiveAgentId;return e&&this.chatStore.llmConfig[e]||null},editableProviders(){return this.localProviders},allModelRefs(){let e=this.localProviders,t=[];for(let s of e){if(!s.name)continue;let n=this.parseModelsFromProvider(s);for(let r of n)t.push(`${s.name}/${r}`)}return t}},watch:{effectiveAgentId:{handler(e,t){e!==t&&(this.cancelPendingDiscovery(),this.cancelPendingSave(),this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,this.loadError=null,this.localProviders=[],this.providerModelsText=[],this.localPrimaryModel=null,this.localFastModel=null,this.isDirty=!1,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null,this.saveRefreshWarning=null),e&&this.requestConfig()},immediate:!0},agentOnline(e){e&&!this.currentConfig&&this.effectiveAgentId&&this.requestConfig()},currentConfig:{handler(e){e&&e.loaded&&this.loadFromConfig(e)},deep:!0}},methods:{async copyText(e){try{await navigator.clipboard.writeText(e),this.$emit("message",this.$t("settings.msg.copiedClipboard"),!1)}catch{this.$emit("message",this.$t("settings.msg.copyFailed"),!0)}},async useGitHubCopilotPreset(){let e=this.effectiveAgentId;if(!e||!this.agentOnline)return;this.cancelPendingDiscovery(),this.discoveringModels=!0,this.modelDiscoveryWarning=null,this.modelDiscoveryError=null;let t=`llm-discovery-${Date.now()}-${Math.random().toString(36).slice(2)}`;this._pendingDiscovery={agentId:e,requestId:t},this.chatStore.sendWsMessage({type:"discover_llm_models",agentId:e,requestId:t,providerType:"github-copilot"});let s=await this.waitForModelDiscovery(e,t);if(!(this._pendingDiscovery?.agentId!==e||this._pendingDiscovery?.requestId!==t||this.effectiveAgentId!==e)){if(this._pendingDiscovery=null,this.discoveringModels=!1,s.error){this.modelDiscoveryError=s.error;return}this.applyDiscoveredProvider(s),this.modelDiscoveryWarning=s.warning||null}},waitForModelDiscovery(e,t){return new Promise(s=>{let n=Date.now(),r=i=>{this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,s(i)};this._resolvePendingDiscovery=r,this._discoveryTimer=setInterval(()=>{let i=this.chatStore.llmModelDiscovery?.[e];if(i?.requestId===t){r(i);return}Date.now()-n>1e4&&r({error:"Timed out while refreshing provider models."})},100)})},cancelPendingDiscovery(){let e=this._resolvePendingDiscovery;this._discoveryTimer&&clearInterval(this._discoveryTimer),this._discoveryTimer=null,this._resolvePendingDiscovery=null,this._pendingDiscovery=null,this.discoveringModels=!1,e&&e({cancelled:!0})},cancelPendingSave(){this._saveTimeout&&(clearTimeout(this._saveTimeout),this._saveTimeout=null),this._saveUnwatch&&(this._saveUnwatch(),this._saveUnwatch=null),this._pendingSave=null,this.saving=!1},applyDiscoveredProvider(e){let t={name:e.provider?.name||"github-copilot",credentialProvider:e.provider?.credentialProvider||"github-copilot",managed:e.provider?.managed||"github-copilot",models:Array.isArray(e.providerModels)&&e.providerModels.length?e.providerModels:e.models||[]},s=[...this.localProviders],n=s.findIndex(o=>o?.name===t.name);n>=0?s[n]=t:s.push(t),this.localProviders=s,this.refreshProviderModelsText();let r=new Set(this.parseModelsFromProvider(t).map(o=>`${t.name}/${o}`)),i=r.values().next().value||null;i&&!r.has(this.localPrimaryModel)&&(this.localPrimaryModel=i),i&&this.localFastModel?.startsWith(`${t.name}/`)&&!r.has(this.localFastModel)&&(this.localFastModel=i),this.markDirty()},requestConfig(){let e=this.effectiveAgentId;if(e){if(!this.agentOnline){this.loading=!1,this.loadError=null;return}this.loading=!0,this.loadError=null,this.chatStore.sendWsMessage({type:"get_llm_config",agentId:e}),this._loadTimeout=setTimeout(()=>{this.loading&&(this.loading=!1,this.loadError="Timeout")},5e3)}},loadFromConfig(e){if(this._loadTimeout&&(clearTimeout(this._loadTimeout),this._loadTimeout=null),this.loading=!1,e.error){this.loadError=e.error;return}this.loadError=null,this.localProviders=(e.agentConfig?.providers||e.providers||[]).map(t=>this.cloneProvider(t)),this.refreshProviderModelsText(),this.localPrimaryModel=e.agentConfig?.primaryModel||e.primaryModel||null,this.localFastModel=e.agentConfig?.fastModel||e.fastModel||null,this.isDirty=!1,this.showApiKey={}},cloneProvider(e){return{type:e.type||"api-key",scope:"agent",name:e.originalName||e.name||"",baseUrl:e.baseUrl||"",apiKey:e.apiKey||"",githubToken:e.githubToken||"",protocol:e.protocol||"openai-responses",credentialProvider:e.credentialProvider||null,models:Array.isArray(e.models)?e.models.map(t=>t&&typeof t=="object"?{...t}:t):[]}},refreshProviderModelsText(){this.providerModelsText=this.editableProviders.map(e=>(e.models||[]).map(t=>this._modelId(t)).join(", "))},parseModelsFromProvider(e){return this.isManagedProvider(e)&&(!Array.isArray(e.models)||e.models.length===0)?this.fallbackCopilotModels():Array.isArray(e.models)?e.models.map(t=>this._modelId(t)).filter(t=>t):[]},_modelId(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.id=="string"?e.id:""},isManagedProvider(e){return e?.managed==="github-copilot"||e?.credentialProvider==="github-copilot"||e?.name==="github-copilot"},fallbackCopilotModels(){return["gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5-mini","gpt-5.3-codex","gpt-5.2-codex","gpt-4.1","gpt-4o","gpt-4o-mini","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-sonnet-4.5","claude-haiku-4.5","gemini-2.5-pro"]},addProvider(){this.editableProviders.push({name:"",baseUrl:"",apiKey:"",protocol:"openai",credentialProvider:null,models:[]}),this.providerModelsText.push(""),this.markDirty()},onPresetPick(e){if(this.showPresetPicker=!1,!e||!e.name)return;let t=new Set(this.editableProviders.map(i=>(i.name||"").trim())),s=e.name,n=2;for(;t.has(s);)s=`${e.name}-${n++}`;let r=Array.isArray(e.models)?e.models.filter(Boolean):[];this.editableProviders.push({name:s,baseUrl:e.baseUrl||"",apiKey:"",protocol:e.protocol||"openai",credentialProvider:null,models:r}),this.providerModelsText.push(r.join(", ")),this.markDirty()},removeProvider(e){this.editableProviders.splice(e,1),this.providerModelsText.splice(e,1);let t={};for(let s=0;s<this.editableProviders.length;s++)s<e?t[s]=this.showApiKey[s]:t[s]=this.showApiKey[s+1];this.showApiKey=t,this.markDirty()},onModelsTextChange(e,t){let s=t.target.value;this.providerModelsText[e]=s;let n=Array.isArray(this.editableProviders[e].models)?this.editableProviders[e].models:[],r=new Map;for(let i of n){let o=this._modelId(i);o&&r.set(o,i)}this.editableProviders[e].models=s.split(/[\n,]+/).map(i=>i.trim()).filter(i=>i).map(i=>r.has(i)?r.get(i):i),this.markDirty()},setProtocol(e,t){let s=this.editableProviders[e].protocol;if(this.editableProviders[e].protocol=t,this.markDirty(),(this.editableProviders[e].models||[]).filter(r=>r).length===0&&t!==s){let r=this._getModelPresets(t);r.length>0&&(this.editableProviders[e].models=[...r],this.providerModelsText[e]=r.join(", "))}},protocolLabel(e){return e==="anthropic"?this.$t("settings.llm.protocolAnthropic"):e==="openai-responses"?this.$t("settings.llm.protocolOpenAIResponses"):this.$t("settings.llm.protocolOpenAI")},protocolHint(e){return e==="anthropic"?this.$t("settings.llm.protocolHint.anthropic"):e==="openai-responses"?this.$t("settings.llm.protocolHint.openaiResponses"):this.$t("settings.llm.protocolHint.openai")},_getModelPresets(e){return il[e]||il.openai},toggleApiKeyVisibility(e){this.showApiKey={...this.showApiKey,[e]:!this.showApiKey[e]}},toggleDropdown(e){this.openDropdown=this.openDropdown===e?null:e},closeDropdown(e){this.openDropdown===e&&(this.openDropdown=null)},markDirty(){this.isDirty=!0},saveConfig(){let e=this.effectiveAgentId;if(!e||this.saving)return;this.saving=!0,this.saveRefreshWarning=null;let s={providers:this.editableProviders.filter(r=>r.name&&(this.isManagedProvider(r)||r.baseUrl)).map(r=>{if(this.isManagedProvider(r))return{name:r.name.trim()||"github-copilot",credentialProvider:"github-copilot",managed:r.managed||"github-copilot",models:(r.models||[]).filter(o=>this._modelId(o))};let i={type:r.type||"api-key",name:r.name.trim(),baseUrl:r.baseUrl.trim(),apiKey:r.apiKey||"",githubToken:r.githubToken||"",models:(r.models||[]).filter(o=>this._modelId(o))};return r.protocol&&r.protocol!=="openai"&&(i.protocol=r.protocol),r.credentialProvider&&(i.credentialProvider=r.credentialProvider,i.apiKey=""),i}),primaryModel:this.localPrimaryModel||null};this.context!=="yeaft"&&(s.fastModel=this.localFastModel||null);let n=`llm-save-${Date.now()}-${Math.random().toString(36).slice(2)}`;this.cancelPendingSave(),this.saving=!0,this._pendingSave={agentId:e,requestId:n},this.chatStore.sendWsMessage({type:"update_llm_config",agentId:e,requestId:n,config:s}),this._saveTimeout=setTimeout(()=>{this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n||(this.cancelPendingSave(),this.$emit("message",this.$t("settings.llm.saveFailed"),!0))},1e4),this._saveUnwatch=this.$watch("currentConfig",r=>{if(!(!r?.loaded||r.requestId!==n||this.effectiveAgentId!==e||this._pendingSave?.agentId!==e||this._pendingSave?.requestId!==n)){if(this.cancelPendingSave(),r.error){this.$emit("message",r.error,!0);return}this.isDirty=!1,this.saveRefreshWarning=r.statusRefreshError?this.$t("settings.llm.savedRefreshWarning",{error:r.statusRefreshError}):null,this.$emit("message",this.saveRefreshWarning||this.$t("settings.llm.saved"),!!r.statusRefreshError),this.$emit("saved",{warning:this.saveRefreshWarning})}},{deep:!0})}},beforeUnmount(){this._loadTimeout&&clearTimeout(this._loadTimeout),this.cancelPendingDiscovery(),this.cancelPendingSave()}}});function ks(e){let t=(Number(e?.actionRunOpenGeneration)||0)+1;return e&&(e.actionRunOpenGeneration=t),t}var Vi,al=F(()=>{Zf();eg();ol();Ci();tl();ei();Ko();sl();ys();Vi={name:"WorkCenterPage",components:{WorkCenterActionDetail:Xf,WorkCenterSettingsModal:Jf,LlmTab:$i,ModernSelect:Js},mixins:[Kf],data(){return{selectedId:null,selectedActionId:null,narrowPane:"items",mobileWorkItemPane:"conversation",contentStack:[{type:"action-list"}],staleComposerTarget:null,composerTargetValue:"coordinator",actionDetailTab:"messages",actionInputRequestGeneration:0,actionRunOpenGeneration:0,workItemMessage:"",workItemMessageAttachments:[],workItemMessageAttachmentsUploading:!1,workItemMessageSending:!1,workItemMessageError:"",workItemComposerGeneration:0,preserveComposerOnEnvelopeClear:!1,detailLoading:!1,detailError:"",createOpen:!1,settingsOpen:!1,saving:!1,createGeneration:0,llmConfigOpen:!1,search:"",boardVpId:"",boardWorkItemType:"",boardUpdatedRange:"week",mobileBoardLane:"active",deletingWorkItemIds:{},deleteWorkItemError:"",boardQueryTimer:null,expandedActions:{},actionsExpanded:!1,workDirTouched:!1,startTouched:!1,createAttachments:[],attachmentsUploading:!1,previewingAttachmentId:null,attachmentPreviewError:"",attachmentPreviewGeneration:0,form:{requirement:"",workDir:"",reuseMemory:!0,start:!0}}},computed:{store(){return Pinia.useChatStore()},chat(){return this.store},agentId(){return this.store.workCenterAgentId||this.store.currentAgent},agents(){return this.store.agents||[]},onlineAgents(){return this.agents.filter(e=>e?.online&&Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},workCenterAgentOptions(){return this.onlineAgents.map(e=>({value:e.id,label:e.name||e.id}))},watcher(){return this.store.workCenterWatcherByAgent[this.agentId]||null},boardNextCursor(){return this.store.workCenterListPageByAgent[this.agentId]?.nextCursor||null},boardLoadingMore(){return!!this.store.workCenterListMoreLoadingByAgent[this.agentId]},settings(){return this.store.workCenterSettingsByAgent[this.agentId]||null},runtime(){return this.store.workCenterRuntimeByAgent[this.agentId]||null},workItemTypes(){return Array.isArray(this.runtime?.workItemTypes)?this.runtime.workItemTypes:[]},workItemAttachmentsSupported(){return this.runtime?.workItemAttachments===!0},canonicalMessageWireSupported(){return this.agents.find(e=>e?.id===this.agentId)?.capabilities?.includes("work_center_message_v2")===!0},createDefaultWorkDir(){return this.settings?.defaultWorkDir||this.runtime?.defaultWorkDir||""},createDefaultStart(){return this.settings?.startImmediately!==!1},folderPickerAgentId(){return this.agentId||""},defaultWorkDir(){return this.createDefaultWorkDir},items(){return this.store.workCenterItemsByAgent[this.agentId]||[]},loading(){return!!this.store.workCenterLoadingByAgent[this.agentId]},loaded(){return!!this.store.workCenterLoadedByAgent[this.agentId]},error(){return this.store.workCenterErrorByAgent[this.agentId]||null},detail(){return this.store.workCenterDetailByAgent[this.agentId]||null},selected(){return this.detail?.id===this.selectedId?this.detail:this.items.find(e=>e.id===this.selectedId)||null},selectedAction(){return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(t=>t.id===this.selectedActionId)||null},contentRef(){return this.contentStack[this.contentStack.length-1]||{type:"action-list"}},contentIsActionList(){return this.contentRef.type==="action-list"},composerTargetIsCoordinator(){return this.composerTargetValue==="coordinator"},composerTargetAction(){if(!this.composerTargetValue.startsWith("action:"))return null;let[,e,t]=this.composerTargetValue.split(":"),s=Number(t);return(Array.isArray(this.selected?.actions)?this.selected.actions:[]).find(r=>r.id===e&&Number(r.generation)===s)||null},composerTargetIsStale(){return this.composerTargetValue!=="coordinator"&&!this.composerTargetAction},composerTargetOptions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[];return[{value:"coordinator",label:this.tr("workCenter.coordinator","Coordinator"),disabled:!1},...e.map(t=>({value:`action:${t.id}:${t.generation}`,label:this.$t("workCenter.composerTargetAction",{sequence:this.actionSequence(t),name:t.brief?.objective||this.actionLabel(t.type)}),disabled:!this.canMessageAction(t)}))]},composerTargetLabel(){return this.composerTargetAction?this.composerTargetAction.brief?.objective||this.actionLabel(this.composerTargetAction.type):this.tr("workCenter.coordinator","Coordinator")},composerPlaceholder(){return this.composerTargetAction?this.$t("workCenter.actionChatPlaceholder",{name:this.composerTargetLabel}):this.tr("workCenter.conversationPlaceholder","Message about this work item")},composerTargetUnavailable(){return this.coordinatorReadOnly?!0:this.composerTargetIsCoordinator?this.coordinatorThinking:this.composerTargetAction?!this.canMessageAction(this.composerTargetAction):!0},composerCanSend(){return!this.workItemMessageSending&&!this.workItemMessageAttachmentsUploading&&!this.composerTargetUnavailable&&(!!this.workItemMessage.trim()||this.workItemMessageAttachments.length>0)},pendingMessageEnvelope(){return this.selected?.id?this.store.loadWorkCenterMessageEnvelope(this.agentId,this.selected.id):null},composerDraftLocked(){return!!this.pendingMessageEnvelope&&!this.composerTargetIsStale},pendingEnvelopeHasAttachments(){return Array.isArray(this.pendingMessageEnvelope?.attachments)&&this.pendingMessageEnvelope.attachments.length>0},pendingEnvelopeAttachmentRecovery(){return this.composerDraftLocked&&this.pendingEnvelopeHasAttachments},actionRequestKey(){return this.selected?.id&&this.selectedAction?.id?Dn(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},actionMessageKey(){return this.selected?.id&&this.selectedAction?.id?qs(this.agentId,this.selected.id,this.selectedAction.id,this.selectedAction.generation):""},workItemComposerScope(){return this.selected?.id?`${this.agentId}:${this.selected.id}:${this.workItemComposerGeneration}`:""},coordinatorThinking(){return(this.selected?.messages||[]).some(e=>e?.role==="assistant"&&e.status==="thinking")},coordinatorReadOnly(){return["done","cancelled"].includes(this.selected?.status)},actionMessages(){let e=Array.isArray(this.selectedAction?.messages)?this.selectedAction.messages:[],t=(Array.isArray(this.selectedAction?.thread)?this.selectedAction.thread:[]).flatMap(o=>Array.isArray(o?.messages)?o.messages:[]),s=this.store.workCenterActionMessages[this.actionMessageKey]?.messages||[],n=En(t,s,e),r=this.selectedAction?.liveMessage,i=r&&n.some(o=>o.role==="assistant"&&o.runId!=null&&o.runId===r.runId&&(r.status==="running"?o.text===r.text:o.status!=="running"));return En(n,i?null:r)},actionMessagesNextCursor(){let e=this.store.workCenterActionMessages[this.actionMessageKey];return e?e.nextCursor:this.selectedAction?.messageCursor},actionMessagesLoading(){return!!this.store.workCenterActionMessagesLoading[this.actionMessageKey]},actionMessagesError(){return this.store.workCenterActionMessagesError[this.actionMessageKey]||""},orderedActions(){let e=Array.isArray(this.selected?.actions)?this.selected.actions:[],t={running:0,waiting:1,failed:2,ready:3,completed:4,done:4,superseded:5,cancelled:6};return e.map((s,n)=>({action:s,index:n})).sort((s,n)=>{let r=t[s.action?.status]??7,i=t[n.action?.status]??7;if(r!==i)return r-i;let o=Number(s.action?.sequence),a=Number(n.action?.sequence);return Number.isFinite(o)&&Number.isFinite(a)&&o!==a?o-a:s.index-n.index}).map(s=>s.action)},actionRequests(){return this.store.workCenterActionRequests[this.actionRequestKey]||[]},actionRequestDetails(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,this.store.workCenterActionRequestDetails[`${this.actionRequestKey}:${t}`]||null]})):{}},actionRequestDetailsLoading(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,!!this.store.workCenterActionRequestDetailsLoading[`${this.actionRequestKey}:${t}`]]})):{}},actionRequestDetailsError(){return this.actionRequestKey?Object.fromEntries(this.actionRequests.map(e=>{let t=bs(e);return[t,this.store.workCenterActionRequestDetailsError[`${this.actionRequestKey}:${t}`]||""]})):{}},actionRequestsLoading(){return!!this.store.workCenterActionRequestsLoading[this.actionRequestKey]},actionRequestsError(){return this.store.workCenterActionRequestsError[this.actionRequestKey]||""},boardLanes(){return[{id:"active",title:this.tr("workCenter.board.active","Active")},{id:"needs_attention",title:this.tr("workCenter.board.needsAttention","Needs attention")},{id:"closed",title:this.tr("workCenter.board.closed","Closed")}].map(e=>({...e,items:this.items.filter(t=>t.boardLane===e.id)}))},boardExecutorOptions(){let e=new Map;for(let t of this.items)for(let s of Array.isArray(t.executors)?t.executors:[])s?.id&&e.set(s.id,s.name||s.id);return[...e.entries()].map(([t,s])=>({id:t,name:s}))},boardTypeOptions(){return[...new Set(this.items.map(e=>e.workItemType).filter(Boolean))].sort()},emptyState(){return{title:this.search.trim()?this.tr("workCenter.noMatchesTitle","No matching work items"):this.tr("workCenter.emptyTitle","No work items yet"),body:this.search.trim()?this.tr("workCenter.noMatchesBody","Try a different search or filter."):this.tr("workCenter.emptyBody","Create a persistent task when work must continue beyond one conversation turn."),canCreate:!this.search.trim()}}},watch:{agentId:{immediate:!0,handler(e,t){ks(this),this.createGeneration=(Number(this.createGeneration)||0)+1,this.saving=!1,this.selectedId=null,this.selectedActionId=null,this.resetWorkItemComposer?.(),this.resetContentStack?.(),this.composerTargetValue="coordinator",this.narrowPane="items",this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&e!==t&&(this.closeFolderPicker(),this.resetCreateExecutionContext(e)),e&&((typeof this.boardFilters=="function"?this.store.listWorkItems(e,this.boardFilters()):this.store.listWorkItems(e)).catch(()=>{}),this.store.loadWorkCenterSettings(e).catch(()=>{}))}},createDefaultWorkDir(){this.applyCreateDefaults()},createDefaultStart(){this.applyCreateDefaults()},search(){this.scheduleBoardQuery()},boardVpId(){this.scheduleBoardQuery()},boardWorkItemType(){this.scheduleBoardQuery()},boardUpdatedRange(){this.scheduleBoardQuery()},"detail.coordinatorRevision"(){this.$nextTick(()=>{let e=this.$el?.querySelector?.(".work-center-item-message-list");e&&(e.scrollTop=e.scrollHeight)})},pendingMessageEnvelope(e,t){if(!(!t||e||t.workItemId!==this.selectedId)){if(this.preserveComposerOnEnvelopeClear){this.preserveComposerOnEnvelopeClear=!1,this.workItemMessageError="",this.workItemMessageSending=!1;return}this.workItemMessage="",this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1,this.$nextTick(()=>this.resizeWorkItemComposer(this.$refs.workItemComposerInput,!0))}},detail:{deep:!0,handler(e){if(!e||e.id!==this.selectedId)return;let t=Array.isArray(e.actions)?e.actions:[];this.selectedActionId&&!t.some(s=>s.id===this.selectedActionId)&&(ks(this),this.selectedActionId=null,this.resetContentStack(),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.staleComposerTarget=this.composerTargetValue:this.staleComposerTarget=null}}},beforeUnmount(){ks(this),this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),window.removeEventListener("popstate",this.restoreWorkCenterUrl)},mounted(){window.addEventListener("popstate",this.restoreWorkCenterUrl),this.restoreWorkCenterUrl();let e=this.store.workCenterCreateDraft;e&&(this.form={requirement:e.requirement||e.goal||e.title||"",workDir:e.workDir||"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.createOpen=!0,this.workDirTouched=!!String(e.workDir||"").trim(),this.startTouched=!1,this.applyCreateDefaults())},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,closeLlmConfigFromOverlay(e){Ze(e)&&(this.llmConfigOpen=!1)},tr(e,t){let s=this.$t?this.$t(e):e;return s&&s!==e?s:t},selectWorkCenterAgent(e){!e||e===this.agentId||this.store.enterWorkCenter(e)},statusLabel(e){return this.tr(`workCenter.status.${e}`,String(e||"").replace("_"," "))},actionLabel(e){return this.tr(`workCenter.action.${e}`,e||"\u2014")},actionSequence(e){let t=Number(e?.sequence);if(Number.isFinite(t)&&t>0)return t;let n=(Array.isArray(this.selected?.actions)?this.selected.actions:[]).findIndex(r=>r?.id===e?.id);return n>=0?n+1:1},actionBreadcrumbDescription(e){return String(e?.brief?.objective||e?.objective||this.actionContentSummary(e)||"").trim().replace(/\s+/g," ")||this.tr("workCenter.untitledAction","Untitled Action")},itemActionProgress(e){let t=Math.max(0,Number(e?.actionCount)||0),s=Math.min(t,Math.max(0,Number(e?.completedActionCount)||0));return this.$t("workCenter.actionProgress",{completed:s,total:t})},time(e){if(!e)return"";try{return new Date(Number(e)).toLocaleString()}catch{return""}},resizeWorkItemComposer(e,t=!1){if(!e)return;e.style.height="auto";let s=t?24:Math.min(e.scrollHeight,144);e.style.height=`${s}px`,e.style.overflowY=e.scrollHeight>144?"auto":"hidden"},onWorkItemMessageInput(e){this.workItemMessage=e.target.value,this.saveComposerDraft(),this.resizeWorkItemComposer(e.target,!e.target.value)},onWorkItemMessageKeydown(e){e.key!=="Enter"||e.shiftKey||e.isComposing||(e.preventDefault(),this.sendSelectedWorkItemMessage())},boardFilters(){let e=Date.now(),t=this.boardUpdatedRange==="day"?e-1440*60*1e3:this.boardUpdatedRange==="week"?e-10080*60*1e3:this.boardUpdatedRange==="month"?e-720*60*60*1e3:null;return{keyword:this.search.trim(),vpId:this.boardVpId,workItemType:this.boardWorkItemType,updatedFrom:t,limit:200}},scheduleBoardQuery(){this.boardQueryTimer&&clearTimeout(this.boardQueryTimer),this.boardQueryTimer=setTimeout(()=>{this.boardQueryTimer=null,this.agentId&&this.refresh()},180)},refresh(){return this.store.listWorkItems(this.agentId,this.boardFilters()).catch(()=>{})},loadMoreBoardItems(){return this.store.loadMoreWorkItems(this.agentId).catch(()=>{})},boardAction(e){return e.attentionAction||e.activeAction||e.currentAction||null},boardActionCountLabel(e){let t=e.actionCounts||{},s=[];for(let n of["running","failed","waiting","ready"])Number(t[n])>0&&s.push(`${t[n]} ${this.statusLabel(n)}`);return s.join(" \xB7 ")||this.itemActionProgress(e)},boardExecutorLabel(e){let t=Array.isArray(e.executors)?e.executors:[];if(t.length>0)return t.map(n=>n.name||n.id).join(", ");let s=this.boardAction(e);return s?.assignedVp?.name||s?.assignedVp?.id||this.tr("workCenter.assignment.planned","Planned assignment")},sameContentRef(e,t){return e?.type===t?.type&&e?.actionId===t?.actionId&&e?.runId===t?.runId&&e?.resourceId===t?.resourceId},resetContentStack(e=[{type:"action-list"}]){let t=Array.isArray(e)?e:[e],s=t[0]?.type==="action-list"?t:[{type:"action-list"},...t];this.contentStack=s.length>0?s:[{type:"action-list"}];let n=[...this.contentStack].reverse().find(r=>r.type==="action");this.selectedActionId=this.contentRef.actionId||n?.actionId||null},pushContentRef(e,{replace:t=!1,syncUrl:s=!0}={}){let n=this.contentRef;if(this.sameContentRef(n,e)){this.mobileWorkItemPane="content";return}this.contentStack=e.type==="action-list"?[{type:"action-list"}]:[...this.contentStack,e],this.selectedActionId=e.actionId||this.selectedActionId,this.mobileWorkItemPane="content",s&&this.syncWorkCenterUrl(t)},popContentRef(){if(this.contentStack.length<=1)return;this.contentStack=this.contentStack.slice(0,-1);let e=[...this.contentStack].reverse().find(t=>t.type==="action");this.selectedActionId=e?.actionId||null,this.mobileWorkItemPane="content",this.syncWorkCenterUrl()},contentRefParam(e){return e.type==="action"&&e.actionId?`action:${e.actionId}`:e.type==="run"&&e.actionId&&e.runId?`run:${e.actionId}:${e.runId}`:e.type==="attachment"&&e.resourceId?`attachment:${e.actionId||"-"}:${e.resourceId}`:"action-list"},contentStackParam(){return this.contentStack.map(e=>this.contentRefParam(e)).join("/")},parseContentRef(e){let t=String(e||"");if(t==="action-list")return{type:"action-list"};if(t.startsWith("action:"))return{type:"action",actionId:t.slice(7)};if(t.startsWith("run:")){let[,s,n]=t.split(":");return{type:"run",actionId:s,runId:n}}if(t.startsWith("attachment:")){let[,s,n]=t.split(":");return{type:"attachment",actionId:s==="-"?null:s,resourceId:n}}return{type:"action-list"}},parseContentStack(e){let t=String(e||"").split("/").filter(Boolean).map(s=>this.parseContentRef(s));return t.length>0?t:[{type:"action-list"}]},syncWorkCenterUrl(e=!1){let t=new URL(window.location.href);this.selectedId?(t.searchParams.set("workAgentId",this.agentId||""),t.searchParams.set("workItemId",this.selectedId),t.searchParams.set("workContent",this.contentStackParam())):(t.searchParams.delete("workAgentId"),t.searchParams.delete("workItemId"),t.searchParams.delete("workContent"));let s=`${t.pathname}${t.search}${t.hash}`;if(`${window.location.pathname}${window.location.search}${window.location.hash}`===s)return;let n={...window.history.state,workCenter:!!this.selectedId,workCenterContent:!!this.selectedId&&this.contentStack.length>1};window.history[e?"replaceState":"pushState"](n,"",s)},async restoreWorkCenterUrl(){let e=new URLSearchParams(window.location.search),t=e.get("workAgentId"),s=e.get("workItemId");if(!s||t&&t!==this.agentId){this.selectedId&&this.showItemsPane({syncUrl:!1});return}let n=this.parseContentStack(e.get("workContent")),r=n.at(-1);if(this.selectedId!==s||this.detail?.id!==s){this.openWorkItem(s,{syncUrl:!1,contentRefs:n}),this.detailLoading=!0;try{await this.store.getWorkItem(s,this.agentId)}catch(o){this.selectedId===s&&(this.detailError=o?.message||String(o))}finally{this.selectedId===s&&(this.detailLoading=!1)}}let i=r.actionId||[...n].reverse().find(o=>o.type==="action")?.actionId;if(i&&!this.selected?.actions?.some(o=>o.id===i)){this.resetContentStack(),this.syncWorkCenterUrl(!0);return}this.resetContentStack(n),this.narrowPane="work-item",this.mobileWorkItemPane=r.type==="action-list"?"conversation":"content",i&&this.loadLatestActionMessages(this.selectedAction)},resetWorkItemComposer(){this.workItemComposerGeneration+=1,this.workItemMessage="",this.workItemMessageAttachments=[],this.workItemMessageAttachmentsUploading=!1,this.workItemMessageError="",this.workItemMessageSending=!1},draftTarget(){let e=this.composerTargetAction;return e?{kind:"action",actionId:e.id,generation:Number(e.generation)}:this.composerTargetValue==="coordinator"?{kind:"coordinator"}:(()=>{let[,t="",s="0"]=this.composerTargetValue.split(":");return{kind:"action",actionId:t,generation:Number(s)||0}})()},targetValue(e){return typeof e=="string"&&e.startsWith("action:")?e:e?.kind==="action"?`action:${e.actionId}:${e.generation}`:"coordinator"},saveComposerDraft(){!this.selectedId||!this.agentId||this.store.saveWorkCenterComposerDraft(this.agentId,this.selectedId,{text:this.workItemMessage,attachments:[...this.workItemMessageAttachments],target:this.draftTarget(),error:this.workItemMessageError})},restoreComposerDraft(e){let s=this.store.loadWorkCenterMessageEnvelope(this.agentId,e)||this.store.loadWorkCenterComposerDraft(this.agentId,e);this.workItemMessage=s?.text||"",this.workItemMessageAttachments=[...s?.attachments||[]],this.composerTargetValue=this.targetValue(s?.target),this.workItemMessageError=s?.error||"",this.staleComposerTarget=null,this.workItemMessageSending=!1,this.workItemMessageAttachmentsUploading=!1,this.workItemComposerGeneration+=1},openWorkItem(e,{syncUrl:t=!0,contentRefs:s=[{type:"action-list"}]}={}){this.saveComposerDraft(),ks(this),this.selectedId=e,this.narrowPane="work-item",this.mobileWorkItemPane="conversation",this.resetContentStack(s),this.restoreComposerDraft(e),this.expandedActions={},this.actionsExpanded=!1,this.detailError="",this.detailLoading=!1,this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1,t&&this.syncWorkCenterUrl()},async selectItem(e){this.openWorkItem(e.id),this.detailLoading=!0;try{await this.store.getWorkItem(e.id,this.agentId)}catch(t){this.selectedId===e.id&&(this.detailError=t?.message||String(t))}finally{this.selectedId===e.id&&(this.detailLoading=!1)}},selectAction(e){this.selectedActionId!==e.id&&(ks(this),this.previewingAttachmentId=null,this.attachmentPreviewError="",this.attachmentPreviewGeneration=(Number(this.attachmentPreviewGeneration)||0)+1),this.pushContentRef({type:"action",actionId:e.id}),this.loadLatestActionMessages(e)},loadLatestActionMessages(e=this.selectedAction){if(!this.selected?.id||!e?.id||Array.isArray(e.messages))return null;let t=qs(this.agentId,this.selected.id,e.id,e.generation);return this.store.workCenterActionMessages[t]?null:this.store.loadWorkItemActionMessages(this.selected.id,e.id,e.generation,null,this.agentId).catch(()=>null)},showItemsPane({syncUrl:e=!0}={}){this.saveComposerDraft(),this.narrowPane="items",this.selectedId=null,this.resetContentStack(),this.composerTargetValue="coordinator",this.resetWorkItemComposer(),e&&this.syncWorkCenterUrl()},showActionsPane(){this.mobileWorkItemPane="content",this.contentIsActionList||this.popContentRef()},canMessageAction(e){return!e||["done","cancelled"].includes(this.selected?.status)?!1:["idle","ready","running","paused","waiting","failed","completed","stopped"].includes(e.status)&&e.admissionStatus!=="blocked"},chooseCoordinatorTarget(){this.pendingMessageEnvelope&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.composerTargetValue="coordinator",this.staleComposerTarget=null,this.saveComposerDraft()},onComposerTargetChange(){this.pendingMessageEnvelope&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.staleComposerTarget=this.composerTargetAction==null&&this.composerTargetValue!=="coordinator"?this.composerTargetValue:null,this.saveComposerDraft()},setComposerTargetForAction(e=this.selectedAction){if(!e?.id||!this.canMessageAction(e))return;let t=`action:${e.id}:${e.generation}`;this.pendingMessageEnvelope&&this.composerTargetValue!==t&&this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId),this.composerTargetValue=t,this.staleComposerTarget=null,this.saveComposerDraft(),this.mobileWorkItemPane="conversation",this.$nextTick(()=>this.$refs.workItemComposerInput?.focus())},loadEarlierActionMessages(){return!this.selected?.id||!this.selectedAction?.id||this.actionMessagesNextCursor==null?null:this.store.loadWorkItemActionMessages(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.actionMessagesNextCursor,this.agentId).catch(()=>null)},async refreshActionRequests(){return!this.selected?.id||!this.selectedAction?.id?[]:this.store.loadWorkItemActionRequests(this.selected.id,this.selectedAction.id,this.selectedAction.generation,this.agentId).catch(()=>[])},loadActionRequest(e){return!this.selected?.id||!this.selectedAction?.id||!e?.id?null:this.store.loadWorkItemActionRequest(this.selected.id,this.selectedAction.id,this.selectedAction.generation,e.runId,e.id,this.agentId).catch(()=>null)},async openActionRun(e,t){let s=ks(this),n={agentId:this.agentId,workItemId:this.selected?.id,actionId:this.selectedAction?.id,generation:this.selectedAction?.generation,runId:e?.id},r=()=>this.actionRunOpenGeneration===s&&this.agentId===n.agentId&&this.selected?.id===n.workItemId&&this.selectedAction?.id===n.actionId&&this.selectedAction?.generation===n.generation;if(!n.workItemId||!n.actionId||!n.runId)return t?.(null);let i=await this.store.loadWorkItemActionRequests(n.workItemId,n.actionId,n.generation,n.agentId).catch(()=>[]);if(!r())return t?.(null);let o=i.find(l=>l.runId===n.runId)||null;return!o||!await this.store.loadWorkItemActionRequest(n.workItemId,n.actionId,n.generation,o.runId,o.id,n.agentId).catch(()=>null)||!r()?t?.(null):(this.pushContentRef({type:"run",actionId:n.actionId,runId:n.runId}),t?.(o))},actionHasDetail(e){return!!e?.brief||Array.isArray(e?.messages)&&e.messages.length>0||!!String(e?.response||"").trim()||!!String(e?.failureReason||"").trim()},actionExpanded(e){return!!this.expandedActions[e?.id]},toggleAction(e){this.actionHasDetail(e)&&(this.expandedActions={...this.expandedActions,[e.id]:!this.expandedActions[e.id]})},actionResponseText(e){return String(e?.response||"").trim()},actionExecutor(e){return e?.assignedVp?.name||e?.assignedVp?.id||e?.requiredRole||e?.assignmentPolicy?.fixedVpId||e?.assignmentPolicy?.capability||this.tr("workCenter.assignment.auto","Auto")},actionContentSummary(e){return String(e?.contentSummary||e?.response||e?.brief?.objective||"").trim()},executionStats(e){return e?.executionStats||{}},formatCount(e){return new Intl.NumberFormat().format(Math.max(0,Number(e)||0))},formatTokens(e){let t=Math.max(0,Number(e)||0);return t>=1e6?`${(t/1e6).toFixed(1)}m`:t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},resetCreateExecutionContext(e){let t=this.workDirTouched||this.startTouched,s=this.store.workCenterCreateDraft;s&&(this.store.workCenterCreateDraft={sourceAgentId:e||null,requirement:s.requirement||s.goal||s.title||"",workDir:"",origin:null,linkedSessionIds:[]}),this.form.workDir="",this.form.start=!0,this.workDirTouched=!1,this.startTouched=!1,t&&(this.createOpen=!1),this.applyCreateDefaults()},applyCreateDefaults(){this.createOpen&&(!this.workDirTouched&&!this.form.workDir.trim()&&(this.form.workDir=this.createDefaultWorkDir),this.startTouched||(this.form.start=this.createDefaultStart))},folderPickerInitialDir(){return this.form.workDir.trim()||this.createDefaultWorkDir},folderPickerSetWorkDir(e){this.form.workDir=e,this.workDirTouched=!0},onCreateWorkDirInput(){this.workDirTouched=!0},onCreateStartInput(){this.startTouched=!0},async onCreateAttachmentInput(e){if(!this.workItemAttachmentsSupported)throw e.target.value="",new Error(this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments."));let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=Math.max(0,10-this.createAttachments.length),n=t.slice(0,s);if(n.length!==0){this.attachmentsUploading=!0;try{let r=new FormData;for(let d of n)r.append("files",d,d.name||"attachment");let i=Pinia.useAuthStore(),o=i.getActiveToken?.()||i.token||null,a=o?{Authorization:`Bearer ${o}`}:{},l=await fetch("/api/upload",{method:"POST",headers:a,body:r});if(!l.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let c=await l.json();this.createAttachments=[...this.createAttachments,...Array.isArray(c.files)?c.files:[]].slice(0,10)}finally{this.attachmentsUploading=!1}}},removeCreateAttachment(e){this.createAttachments=this.createAttachments.filter((t,s)=>s!==e)},discardPendingMessageEnvelope(){if(!(!this.selectedId||!this.pendingMessageEnvelope)){if(this.actionInputRequestGeneration=(Number(this.actionInputRequestGeneration)||0)+1,this.preserveComposerOnEnvelopeClear=!0,!this.store.discardWorkCenterMessageEnvelope(this.agentId,this.selectedId)){this.preserveComposerOnEnvelopeClear=!1;return}this.workItemMessageAttachments=[],this.workItemMessageError="",this.workItemMessageSending=!1,this.saveComposerDraft()}},async onWorkItemMessageAttachmentInput(e){if(!this.workItemAttachmentsSupported){e.target.value="",this.workItemMessageError=this.tr("workCenter.attachmentsUnsupported","The selected Agent does not support Work Item attachments.");return}let t=Array.from(e.target.files||[]);if(e.target.value="",t.length===0)return;let s=this.workItemComposerScope;if(!s)return;let n=this.pendingEnvelopeAttachmentRecovery,r=Array.isArray(this.selected?.attachments)?this.selected.attachments.length:0,i=Math.max(0,10-r-(n?0:this.workItemMessageAttachments.length)),o=t.slice(0,i);if(o.length!==0){this.workItemMessageAttachmentsUploading=!0,this.workItemMessageError="";try{let a=new FormData;for(let g of o)a.append("files",g,g.name||"attachment");let l=Pinia.useAuthStore(),c=l.getActiveToken?.()||l.token||null,d=c?{Authorization:`Bearer ${c}`}:{},u=await fetch("/api/upload",{method:"POST",headers:d,body:a});if(!u.ok)throw new Error(this.tr("workCenter.attachmentsUploadFailed","Attachment upload failed"));let f=await u.json();if(this.workItemComposerScope!==s)return;let p=(Array.isArray(f.files)?f.files:[]).slice(0,Math.max(0,10-r));if(n){let g=this.store.replaceWorkCenterMessageEnvelopeAttachments(this.agentId,this.selectedId,p);if(!g)throw new Error(this.tr("workCenter.pendingEnvelopeChanged","The pending request changed; reopen this Work Item and try again."));this.workItemMessageAttachments=[...g.attachments],this.workItemMessageError=""}else this.workItemMessageAttachments=[...this.workItemMessageAttachments,...p].slice(0,Math.max(0,10-r)),this.saveComposerDraft()}catch(a){this.workItemComposerScope===s&&(this.workItemMessageError=a?.message||String(a))}finally{this.workItemComposerScope===s&&(this.workItemMessageAttachmentsUploading=!1)}}},removeWorkItemMessageAttachment(e){this.workItemMessageAttachments=this.workItemMessageAttachments.filter((t,s)=>s!==e),this.saveComposerDraft()},async previewAttachment(e,t=null){if(!this.selected?.id||!e?.id||this.previewingAttachmentId)return;this.pushContentRef({type:"attachment",actionId:this.selectedActionId||null,resourceId:e.id});let s=this.agentId,n=this.selected.id,r=this.selectedActionId||"",i=`${s}:${n}:${r}`,o=(Number(this.attachmentPreviewGeneration)||0)+1;this.attachmentPreviewGeneration=o;let a=()=>this.attachmentPreviewGeneration===o&&`${this.agentId}:${this.selected?.id||""}:${this.selectedActionId||""}`===i,l=e.isImage?null:window.open("","_blank");if(!e.isImage&&!l){this.attachmentPreviewError=this.tr("workCenter.attachmentOpenBlocked","The browser blocked the attachment window. Allow pop-ups and try again.");return}l&&(l.opener=null),this.previewingAttachmentId=e.id,this.attachmentPreviewError="";try{let c=await this.store.previewWorkItemAttachment(n,e.id,s);if(!a()){l?.close();return}c?.preview&&c.attachment?.isImage?js(c.preview,{alt:e.name||this.tr("workCenter.previewAttachment","Open attachment"),closeLabel:this.tr("common.close","Close"),trigger:t}):c?.preview&&l?l.location.replace(c.preview):l?.close()}catch(c){l?.close(),a()&&(this.attachmentPreviewError=c?.message||this.tr("workCenter.attachmentPreviewFailed","Could not open the attachment. Try again."))}finally{a()&&(this.previewingAttachmentId=null)}},formatAttachmentSize(e){let t=Math.max(0,Number(e)||0);return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/1024/1024).toFixed(1)} MB`},openCreate(){this.createOpen=!0,this.workDirTouched=!1,this.startTouched=!1,this.applyCreateDefaults()},closeCreate(){this.saving||(this.closeFolderPicker(),this.createOpen=!1,this.store.workCenterCreateDraft=null)},onLlmConfigSaved(){let e=this.agentId;if(e)return this.store.refreshWorkCenterRuntime(e).catch(()=>{})},async submitCreate(){let e=String(this.form.requirement||this.form.goal||this.form.title||"").trim();if(!e||!this.form.workDir.trim())return;let t=this.agentId,s=(Number(this.createGeneration)||0)+1;this.createGeneration=s,this.saving=!0;try{let n=this.store.workCenterCreateDraft,r=n?.sourceAgentId===t,i=await this.store.createWorkItem({requirement:e,title:e,goal:e,acceptanceCriteria:[],workItemType:"auto",workDir:this.form.workDir.trim(),origin:r&&n.origin||null,linkedSessionIds:r?n.linkedSessionIds||[]:[],attachments:this.workItemAttachmentsSupported?(this.createAttachments||[]).map(o=>({fileId:o.fileId,name:o.name,mimeType:o.mimeType,size:o.size})):[],reuseMemory:this.form.reuseMemory,start:this.form.start},t);if(this.agentId!==t||this.createGeneration!==s)return;this.openWorkItem(i.id),this.form={requirement:"",workDir:"",reuseMemory:!0,start:this.settings?.startImmediately!==!1},this.store.workCenterCreateDraft=null,this.createAttachments=[],this.workDirTouched=!1,this.startTouched=!1,this.createOpen=!1}finally{this.agentId===t&&this.createGeneration===s&&(this.saving=!1)}},async startSelected(){this.selected&&await this.store.startWorkItem(this.selected.id,this.agentId)},async sendSelectedWorkItemMessage(){if(!this.selected||!this.composerCanSend)return;let e=this.workItemComposerScope,t=this.composerTargetValue,s=this.composerTargetAction;if(!this.composerTargetIsCoordinator&&!s)return;let n=this.selected.id,r=this.selected.revision,i=this.workItemMessage.trim(),o=this.workItemMessageAttachments.map(l=>({fileId:l.fileId,name:l.name,mimeType:l.mimeType,size:l.size})),a=(Number(this.actionInputRequestGeneration)||0)+1;this.actionInputRequestGeneration=a,this.workItemMessageSending=!0,this.workItemMessageError="",this.saveComposerDraft();try{let l={planRevision:this.selected.planRevision,ledgerRevision:this.selected.ledgerRevision,coordinatorRevision:this.selected.coordinatorRevision};this.canonicalMessageWireSupported?await this.store.postWorkItemMessage(n,i,s?{kind:"action",actionId:s.id,generation:s.generation}:{kind:"coordinator"},r,o,this.agentId,l):s?await this.store.sendWorkItemActionInput(n,i,s.id,r,s.generation,o,this.agentId):await this.store.sendWorkItemMessage(n,i,r,o,this.agentId,l),this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&this.composerTargetValue===t&&this.workItemMessage.trim()===i&&!this.store.loadWorkCenterMessageEnvelope(this.agentId,n)&&(this.workItemMessage="",this.workItemMessageAttachments=[],this.store.removeWorkCenterComposerDraft(this.agentId,n),this.$nextTick(()=>this.resizeWorkItemComposer(this.$refs.workItemComposerInput,!0)))}catch(l){this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&(this.workItemMessageError=l?.message||String(l),this.saveComposerDraft())}finally{this.workItemComposerScope===e&&this.actionInputRequestGeneration===a&&(this.workItemMessageSending=!1)}},workItemCanDelete(e){return["done","cancelled","draft","needs_attention"].includes(e?.status)},workItemDeleting(e){return!!this.deletingWorkItemIds[e?.id]},async deleteWorkItem(e){if(!e||this.workItemDeleting(e))return;let t=this.tr("workCenter.deleteConfirm","Permanently delete this Work Item, its execution history, and attachments?");if(!(typeof confirm=="function"&&!confirm(t))){this.deleteWorkItemError="",this.deletingWorkItemIds={...this.deletingWorkItemIds,[e.id]:!0};try{let s=await this.store.deleteWorkItem(e.id,e.revision,this.agentId);s?.cleanupWarning&&(this.deleteWorkItemError=s.cleanupWarning),this.selectedId===e.id&&(ks(this),this.showItemsPane())}catch(s){this.deleteWorkItemError=s?.message||String(s)}finally{let s={...this.deletingWorkItemIds};delete s[e.id],this.deletingWorkItemIds=s}}},async cancelSelected(){if(!this.selected||["done","cancelled"].includes(this.selected.status))return;let e=this.tr("workCenter.cancelConfirm","Stop this work item and its unfinished Actions?");typeof confirm=="function"&&!confirm(e)||await this.store.cancelWorkItem(this.selected.id,this.agentId)},async resumeSelected(){!this.selected||this.selected.status!=="cancelled"||await this.store.resumeWorkItem(this.selected.id,this.selected.revision,this.agentId)}},template:`
|
|
5672
5667
|
<main class="work-center-main" :class="{ 'workbench-maximized': store.workbenchMaximized && store.workbenchExpanded }">
|
|
5673
5668
|
<div class="work-center-shell" :class="{ 'showing-detail': narrowPane !== 'items' }">
|
|
5674
5669
|
<header class="work-center-header">
|
|
@@ -6635,7 +6630,7 @@ ${String(e||"").trim()}
|
|
|
6635
6630
|
</div>
|
|
6636
6631
|
</div>
|
|
6637
6632
|
</div>
|
|
6638
|
-
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},providerOptions(){return[{value:"claude-code",label:this.$t("provider.claudeCode")},{value:"copilot",label:this.$t("provider.copilot")}]},agentOptions(){return this.store.agents.filter(e=>e.online).map(e=>({value:e.id,label:`${e.name}${e.latency?` (${e.latency}ms)`:""}`}))},canUseWorkbench(){let e=_e().role;return e==="admin"||e==="pro"},selectedConvModalAgentWorkDir(){return this.convModalAgent&&this.store.agents.find(t=>t.id===this.convModalAgent)?.workDir||""},onlineAgents(){return this.store.agents.filter(e=>e.online)},onlineAgentCount(){return this.onlineAgents.length},workCenterAgents(){return this.onlineAgents.filter(e=>Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},isMobileView(){return this.windowWidth<=768},effectiveSidebarCollapsed(){return this.isMobileView?!this.store.sessionSidebarOpen:this.store.sidebarCollapsed},normalConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1).length}},methods:{onSidebarCollapse(){rg({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 du(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},openWorkCenter(e=null){let t=this.workCenterAgents.find(s=>s.id===e)||this.workCenterAgents.find(s=>s.id===this.store.workCenterAgentId)||this.workCenterAgents[0];t&&this.store.enterWorkCenter(t.id)},onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;e==="rename"?this.store.renameCatalogSession({row:t,title:s}):e==="reorder"?this.store.reorderCatalogSessions(n):e==="pin"?this.store.toggleCatalogSessionPin(t):e==="remove"&&r!=="yeaft"?confirm(this.$t("chat.delete.confirm"))&&this.closeSession(o,i):r==="yeaft"&&e==="remove"?this.store.sessionCrudRequest("archive",{sessionId:o},{agentId:i}):r==="yeaft"&&e==="settings"&&(this.store.pendingUnifiedSessionSettings={sessionId:o,agentId:i,section:"session"},this.store.openCatalogSession(t))},openConversationModal({preserveProvider:e=!1}={}){this.showConversationModal=!0,e||(this.convModalProvider="claude-code"),this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this._foldersRetried=!1;let t=this.store.agents.filter(r=>r.online),n=t.find(r=>r.id===this.store.currentAgent)||t[0];n&&(this.convModalAgent=n.id,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider).then(()=>{this.showConversationModal&&this.store.folders.length===0&&!this._foldersRetried&&(this._foldersRetried=!0,setTimeout(()=>{this.showConversationModal&&this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},1500))}))},openConversationModalResume(){this.openConversationModal()},closeConversationModal(){this.showConversationModal=!1,this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1},onConvModalAgentChange(){this.convModalAgent&&(this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider))},onConvModalProviderChange(){this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},onConvModalWorkDirInput(){this.historyLoaded=!1,this.selectedResumeSession=null,this._workDirInputTimer&&clearTimeout(this._workDirInputTimer),this._workDirInputTimer=setTimeout(()=>{this.convModalWorkDir.trim()&&this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},500)},selectConvModalFolder(e){this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0)},loadConvModalFolders(){this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},loadConvModalSessions(){this.convModalAgent&&this.convModalWorkDir.trim()&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},toggleAgentDropdown(){this.showAgentDropdown=!this.showAgentDropdown,this.showAgentDropdown&&this.store.refreshAgents()},selectAgent(e){this.store.selectAgent(e),this.showAgentDropdown=!1},createNewConversation(){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent);let e=this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.createConversation(e,this.convModalAgent,null,this.buildConvOpts()),this.closeConversationModal()},buildConvOpts(){let e={provider:this.convModalProvider};return this.convModalProvider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeSession(e){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=e.title;let t=e.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(e.sessionId,t,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},resumeSelectedSession(){if(!this.convModalAgent||!this.selectedResumeSession)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=this.selectedResumeSession.title;let e=this.selectedResumeSession.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(this.selectedResumeSession.sessionId,e,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},formatDate(e){return Ri(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},closeSession(e,t){this.store.closeSession(e,t)},deleteConversation(e,t){confirm(this.$t("chat.delete.confirm"))&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Fi(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Zn(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;confirm(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;confirm(this.$t("chat.agent.upgradeConfirm",{name:s}))&&(this.upgradingAgents[e]={since:Date.now(),oldVersion:t?.version||null},setTimeout(()=>{delete this.upgradingAgents[e]},12e4),this.store.upgradeAgent(e))},openFolderPicker(e){let t=this.convModalAgent;if(!t)return;this.folderPickerTarget=e,this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let s=this.convModalWorkDir,n=this.store.agents.find(o=>o.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:r,workDir:n?.workDir||""})};i(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&i()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=this.store.agents.find(r=>r.id===t),n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:e,workDir:s?.workDir||""})};n(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&n()},5e3)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(s[0]+"\\");else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:/^[A-Z]:$/.test(e.name)?n=e.name+"\\":n="/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0),this.folderPickerOpen=!1}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mounted(){if(this.store.openUnifiedChatCreate){let e=this.store.openUnifiedChatCreate;this.store.openUnifiedChatCreate=!1,this.convModalProvider=e==="copilot"?"copilot":"claude-code",this.openConversationModal({preserveProvider:!0})}this._clickOutsideHandler=e=>{e.target.closest(".agent-selector")||(this.showAgentDropdown=!1),!e.target.closest(".session-dots-btn")&&!e.target.closest(".session-menu")&&(this.activeSessionMenu=null)},document.addEventListener("click",this._clickOutsideHandler),window.addEventListener("resize",this.handleResize),window.addEventListener("workbench-message",this.handleFolderPickerMessage),fetch("/api/version").then(e=>e.json()).then(e=>{this.serverVersion=e.version}).catch(()=>{}),this._agentRestartAckHandler=e=>{let{agentId:t}=e.detail},window.addEventListener("agent-restart-ack",this._agentRestartAckHandler),this._agentUpgradeAckHandler=e=>{let{agentId:t,success:s,error:n,alreadyLatest:r,version:i,reason:o,currentNode:a,requiredNode:l}=e.detail;s?r&&(delete this.upgradingAgents[t],alert(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],alert(o==="node_incompatible"?this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""}):`Agent upgrade failed: ${n||"Unknown error"}`))},window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents=this.$watch(()=>this.store.agents.map(e=>e.id+":"+e.online),()=>{for(let e of Object.keys(this.restartingAgents)){let t=this.store.agents.find(s=>s.id===e);(t?.online||!t)&&delete this.restartingAgents[e]}for(let e of Object.keys(this.upgradingAgents)){let t=this.store.agents.find(r=>r.id===e),s=this.upgradingAgents[e],n=Date.now()-(s?.since||0);!t||n>12e4?delete this.upgradingAgents[e]:t.online&&(n<3e3?setTimeout(()=>{this.store.agents.find(o=>o.id===e)?.online&&delete this.upgradingAgents[e]},3e3-n):delete this.upgradingAgents[e])}})},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-restart-ack",this._agentRestartAckHandler),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents&&this._checkRestartingAgents(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function lg(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((p,g)=>{typeof p=="string"&&p&&!u.has(p)&&u.set(p,g)});let f=[];for(let p of Array.isArray(t)?t:[]){if(!p||!p.id||d&&p.agentId&&!d.has(p.agentId))continue;let g=String(p.id),b=p.agentId?`${p.agentId}${g}`:g;f.push({kind:"session",id:g,raw:p,pinned:!!p.pinned||!p.agentId&&u.has(g),active:l?b===a:g===o,processing:!!p.running||!!p.active||!!p.isRunning||!!p.isActive,_manualOrder:Number.isFinite(p.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:Wr(p)})}return f.sort((p,g)=>{if(p.pinned!==g.pinned)return p.pinned?-1:1;if(p._manualOrder!==g._manualOrder)return p._manualOrder-g._manualOrder;if(p._activityTime!==g._activityTime)return g._activityTime-p._activityTime;let b=u.has(p.id)?u.get(p.id):Number.MAX_SAFE_INTEGER,h=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return b!==h?b-h:p.id.localeCompare(g.id)}),f.map(({_manualOrder:p,_activityTime:g,...b})=>b)}var cg=F(()=>{Ur()});var by,JI,dg,ug=F(()=>{_i();Ka();Ya();Ga();Qa();Xa();ll();cg();by=3600*1e3,JI=24*by,dg={name:"YeaftSidebar",components:{SessionCreateModal:en,SidebarModeToggle:Ai,SidebarAgentHeader:xi,SidebarWorkCenter:Ti,SessionSidebarShell:Mi,UnifiedSessionList:Pi},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
6633
|
+
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},providerOptions(){return[{value:"claude-code",label:this.$t("provider.claudeCode")},{value:"copilot",label:this.$t("provider.copilot")}]},agentOptions(){return this.store.agents.filter(e=>e.online).map(e=>({value:e.id,label:`${e.name}${e.latency?` (${e.latency}ms)`:""}`}))},canUseWorkbench(){let e=_e().role;return e==="admin"||e==="pro"},selectedConvModalAgentWorkDir(){return this.convModalAgent&&this.store.agents.find(t=>t.id===this.convModalAgent)?.workDir||""},onlineAgents(){return this.store.agents.filter(e=>e.online)},onlineAgentCount(){return this.onlineAgents.length},workCenterAgents(){return this.onlineAgents.filter(e=>Array.isArray(e.capabilities)&&e.capabilities.includes("work_center"))},isMobileView(){return this.windowWidth<=768},effectiveSidebarCollapsed(){return this.isMobileView?!this.store.sessionSidebarOpen:this.store.sidebarCollapsed},normalConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1).length}},methods:{onSidebarCollapse(){rg({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 du(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},openWorkCenter(e=null){let t=this.workCenterAgents.find(s=>s.id===e)||this.workCenterAgents.find(s=>s.id===this.store.workCenterAgentId)||this.workCenterAgents[0];t&&this.store.enterWorkCenter(t.id)},onUnifiedSessionAction({action:e,row:t,title:s,sessions:n}={}){if(!t?.routeRef)return;let{runtimeProvider:r,agentId:i,sessionId:o}=t.routeRef;e==="rename"?this.store.renameCatalogSession({row:t,title:s}):e==="reorder"?this.store.reorderCatalogSessions(n):e==="pin"?this.store.toggleCatalogSessionPin(t):e==="remove"&&r!=="yeaft"?confirm(this.$t("chat.delete.confirm"))&&this.closeSession(o,i):r==="yeaft"&&e==="remove"?this.store.sessionCrudRequest("archive",{sessionId:o},{agentId:i}):r==="yeaft"&&e==="settings"&&(this.store.pendingUnifiedSessionSettings={sessionId:o,agentId:i,section:"session"},this.store.openCatalogSession(t))},openConversationModal({preserveProvider:e=!1}={}){this.showConversationModal=!0,e||(this.convModalProvider="claude-code"),this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this._foldersRetried=!1;let t=this.store.agents.filter(r=>r.online),n=t.find(r=>r.id===this.store.currentAgent)||t[0];n&&(this.convModalAgent=n.id,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider).then(()=>{this.showConversationModal&&this.store.folders.length===0&&!this._foldersRetried&&(this._foldersRetried=!0,setTimeout(()=>{this.showConversationModal&&this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},1500))}))},openConversationModalResume(){this.openConversationModal()},closeConversationModal(){this.showConversationModal=!1,this.convModalAgent="",this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1},onConvModalAgentChange(){this.convModalAgent&&(this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider))},onConvModalProviderChange(){this.convModalWorkDir="",this.selectedResumeSession=null,this.historyLoaded=!1,this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},onConvModalWorkDirInput(){this.historyLoaded=!1,this.selectedResumeSession=null,this._workDirInputTimer&&clearTimeout(this._workDirInputTimer),this._workDirInputTimer=setTimeout(()=>{this.convModalWorkDir.trim()&&this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},500)},selectConvModalFolder(e){this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0)},loadConvModalFolders(){this.convModalAgent&&this.store.listFoldersForAgent(this.convModalAgent,this.convModalProvider)},loadConvModalSessions(){this.convModalAgent&&this.convModalWorkDir.trim()&&(this.store.listHistorySessionsForAgent(this.convModalAgent,this.convModalWorkDir.trim(),this.convModalProvider),this.historyLoaded=!0)},toggleAgentDropdown(){this.showAgentDropdown=!this.showAgentDropdown,this.showAgentDropdown&&this.store.refreshAgents()},selectAgent(e){this.store.selectAgent(e),this.showAgentDropdown=!1},createNewConversation(){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent);let e=this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.createConversation(e,this.convModalAgent,null,this.buildConvOpts()),this.closeConversationModal()},buildConvOpts(){let e={provider:this.convModalProvider};return this.convModalProvider==="copilot"&&(e.providerOptions={allowAllTools:!0}),e},resumeSession(e){if(!this.convModalAgent)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=e.title;let t=e.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(e.sessionId,t,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},resumeSelectedSession(){if(!this.convModalAgent||!this.selectedResumeSession)return;this.store.selectAgent(this.convModalAgent),this.store._pendingSessionTitle=this.selectedResumeSession.title;let e=this.selectedResumeSession.workDir||this.convModalWorkDir.trim()||this.selectedConvModalAgentWorkDir;this.store.resumeConversation(this.selectedResumeSession.sessionId,e,this.convModalAgent,this.buildConvOpts()),this.closeConversationModal()},formatDate(e){return Ri(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},closeSession(e,t){this.store.closeSession(e,t)},deleteConversation(e,t){confirm(this.$t("chat.delete.confirm"))&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Fi(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Zn(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;confirm(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;confirm(this.$t("chat.agent.upgradeConfirm",{name:s}))&&(this.upgradingAgents[e]={since:Date.now(),oldVersion:t?.version||null},setTimeout(()=>{delete this.upgradingAgents[e]},12e4),this.store.upgradeAgent(e))},openFolderPicker(e){let t=this.convModalAgent;if(!t)return;this.folderPickerTarget=e,this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let s=this.convModalWorkDir,n=this.store.agents.find(o=>o.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:r,workDir:n?.workDir||""})};i(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&i()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=this.store.agents.find(r=>r.id===t),n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",agentId:t,dirPath:e,workDir:s?.workDir||""})};n(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&n()},5e3)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(s[0]+"\\");else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:/^[A-Z]:$/.test(e.name)?n=e.name+"\\":n="/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0),this.folderPickerOpen=!1}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mounted(){if(this.store.openUnifiedChatCreate){let e=this.store.openUnifiedChatCreate;this.store.openUnifiedChatCreate=!1,this.convModalProvider=e==="copilot"?"copilot":"claude-code",this.openConversationModal({preserveProvider:!0})}this._clickOutsideHandler=e=>{e.target.closest(".agent-selector")||(this.showAgentDropdown=!1),!e.target.closest(".session-dots-btn")&&!e.target.closest(".session-menu")&&(this.activeSessionMenu=null)},document.addEventListener("click",this._clickOutsideHandler),window.addEventListener("resize",this.handleResize),window.addEventListener("workbench-message",this.handleFolderPickerMessage),fetch("/api/version").then(e=>e.json()).then(e=>{this.serverVersion=e.version}).catch(()=>{}),this._agentRestartAckHandler=e=>{let{agentId:t}=e.detail},window.addEventListener("agent-restart-ack",this._agentRestartAckHandler),this._agentUpgradeAckHandler=e=>{let{agentId:t,success:s,error:n,alreadyLatest:r,version:i,reason:o,currentNode:a,requiredNode:l}=e.detail;s?r&&(delete this.upgradingAgents[t],alert(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],alert(o==="node_incompatible"?this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""}):`Agent upgrade failed: ${n||"Unknown error"}`))},window.addEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents=this.$watch(()=>this.store.agents.map(e=>e.id+":"+e.online),()=>{for(let e of Object.keys(this.restartingAgents)){let t=this.store.agents.find(s=>s.id===e);(t?.online||!t)&&delete this.restartingAgents[e]}for(let e of Object.keys(this.upgradingAgents)){let t=this.store.agents.find(r=>r.id===e),s=this.upgradingAgents[e],n=Date.now()-(s?.since||0);!t||n>12e4?delete this.upgradingAgents[e]:t.online&&(n<3e3?setTimeout(()=>{this.store.agents.find(o=>o.id===e)?.online&&delete this.upgradingAgents[e]},3e3-n):delete this.upgradingAgents[e])}})},beforeUnmount(){document.removeEventListener("click",this._clickOutsideHandler),window.removeEventListener("resize",this.handleResize),window.removeEventListener("workbench-message",this.handleFolderPickerMessage),window.removeEventListener("agent-restart-ack",this._agentRestartAckHandler),window.removeEventListener("agent-upgrade-ack",this._agentUpgradeAckHandler),this._checkRestartingAgents&&this._checkRestartingAgents(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer)}}});function lg(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((p,g)=>{typeof p=="string"&&p&&!u.has(p)&&u.set(p,g)});let f=[];for(let p of Array.isArray(t)?t:[]){if(!p||!p.id||d&&p.agentId&&!d.has(p.agentId))continue;let g=String(p.id),b=p.agentId?`${p.agentId}${g}`:g;f.push({kind:"session",id:g,raw:p,pinned:!!p.pinned||!p.agentId&&u.has(g),active:l?b===a:g===o,processing:!!p.running||!!p.active||!!p.isRunning||!!p.isActive,_manualOrder:Number.isFinite(p.sortOrder)?p.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:Wr(p)})}return f.sort((p,g)=>{if(p.pinned!==g.pinned)return p.pinned?-1:1;if(p._manualOrder!==g._manualOrder)return p._manualOrder-g._manualOrder;if(p._activityTime!==g._activityTime)return g._activityTime-p._activityTime;let b=u.has(p.id)?u.get(p.id):Number.MAX_SAFE_INTEGER,h=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return b!==h?b-h:p.id.localeCompare(g.id)}),f.map(({_manualOrder:p,_activityTime:g,...b})=>b)}var cg=F(()=>{Ur()});var wy,eC,dg,ug=F(()=>{_i();Ka();Ya();Ga();Qa();Xa();ll();cg();wy=3600*1e3,eC=24*wy,dg={name:"YeaftSidebar",components:{SessionCreateModal:en,SidebarModeToggle:Ai,SidebarAgentHeader:xi,SidebarWorkCenter:Ti,SessionSidebarShell:Mi,UnifiedSessionList:Pi},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
6639
6634
|
<SessionSidebarShell class="yeaft-sidebar" :collapsed="collapsed">
|
|
6640
6635
|
<template #collapsed>
|
|
6641
6636
|
<!-- Collapsed Icon Bar \u2014 mirrors Chat's .sidebar-collapsed-bar so the
|
|
@@ -6834,7 +6829,7 @@ ${String(e||"").trim()}
|
|
|
6834
6829
|
</div>
|
|
6835
6830
|
</div>
|
|
6836
6831
|
</div>
|
|
6837
|
-
`,mounted(){window.addEventListener("keydown",this.onEsc)},beforeUnmount(){window.removeEventListener("keydown",this.onEsc)},methods:{onEsc(e){e.key==="Escape"&&this.onDismiss()},onOpen(){this.$emit("open-library")},onDismiss(){this.$emit("dismiss")}}}});function cl(e){return e==="members"||e==="memory"||e===
|
|
6832
|
+
`,mounted(){window.addEventListener("keydown",this.onEsc)},beforeUnmount(){window.removeEventListener("keydown",this.onEsc)},methods:{onEsc(e){e.key==="Escape"&&this.onDismiss()},onOpen(){this.$emit("open-library")},onDismiss(){this.$emit("dismiss")}}}});function cl(e){return e==="members"||e==="memory"||e===Yt?e:(ky.has(e),Yt)}var Yt,ky,gg,mg=F(()=>{ys();Kn();Yt="session",ky=new Set(["announcement","rename","danger"]);gg={name:"SessionSettingsModal",emits:["close","open-vp-library"],props:{groupId:{type:String,required:!0},agentId:{type:String,default:null},initialSection:{type:String,default:Yt,validator:e=>[Yt,"announcement","members","rename","memory","danger"].includes(e)},initialEditVpId:{type:String,default:""}},data(){return{section:this.initialEditVpId?"members":cl(this.initialSection),announcementDraft:"",announcementBusy:!1,announcementError:"",renameDraft:"",renameBusy:!1,renameError:"",membersBusy:!1,membersError:"",highlightedVpId:this.initialEditVpId||"",deleteConfirmText:"",deleteBusy:!1,deleteError:""}},computed:{chat(){try{return window.Pinia?.useChatStore?.()||null}catch{return null}},vpStore(){try{return window.Pinia?.useVpStore?.()||null}catch{return null}},sessionsStore(){try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},group(){let e=this.sessionsStore,t=this.agentId||this.chat?.currentAgent||null;return e&&typeof e.sessionById=="function"?e.sessionById(this.groupId,t):null},targetAgentId(){return this.agentId||this.group?.agentId||this.chat?.currentAgent||null},groupDisplayName(){let e=this.group;return e?e.id==="grp_default"&&(e.name==="Default"||!e.name)?this.$t("yeaft.session.defaultName")||e.name||e.id:e.name||e.id:""},announcement(){return this.group&&typeof this.group.announcement=="string"?this.group.announcement:""},roster(){return this.group&&Array.isArray(this.group.roster)?this.group.roster:[]},defaultVpId(){return this.group&&this.group.defaultVpId||null},vpList(){return this.vpStore?.vpList||[]},vpDomainSections(){return hs(this.vpList)},vpLibraryEmpty(){let e=this.vpStore;return e?e.emptyLibrary===!0?!0:!!(e.lastSnapshotAt&&e.lastSnapshotAt>0&&(e.vpOrder?.length||0)===0):!1},deleteConfirmReady(){return this.deleteConfirmText.trim()===this.groupDisplayName},sections(){return[{id:Yt,label:this.$t("yeaft.session.settings.nav.session")},{id:"members",label:this.$t("yeaft.session.settings.nav.members")},{id:"memory",label:this.$t("yeaft.session.settings.nav.memory")}]},groupDreamStatus(){let e=this.vpStore;return e?e.groupDreamStatusFor(this.groupId):{status:"idle",lastRunAt:null,lastResult:null,lastError:null}},dreamRunning(){return this.groupDreamStatus.status==="running"}},watch:{section(e){e===Yt&&(this.announcementDraft=this.announcement,this.renameDraft=this.groupDisplayName),this.announcementError="",this.renameError="",this.membersError="",this.deleteError="",this.deleteConfirmText=""},initialEditVpId(e){this.highlightedVpId=e||"",e&&(this.section="members")},initialSection(e){this.initialEditVpId||(this.section=cl(e))},groupId(){this.section=this.initialEditVpId?"members":cl(this.initialSection),this.highlightedVpId=this.initialEditVpId||"",this.announcementDraft=this.announcement,this.renameDraft=this.groupDisplayName,this.deleteConfirmText="",this.announcementError="",this.renameError="",this.membersError="",this.deleteError=""},group(e,t){t&&!e&&!this.deleteBusy&&this.requestClose()}},mounted(){window.addEventListener("keydown",this.onEsc);try{if(this.vpStore&&this.vpStore.lastSnapshotAt===0){let e=this.chat;e&&typeof e.sendWsMessage=="function"&&e.sendWsMessage({type:"yeaft_vp_subscribe"})}}catch{}this.section===Yt&&(this.announcementDraft=this.announcement,this.renameDraft=this.groupDisplayName)},beforeUnmount(){window.removeEventListener("keydown",this.onEsc)},methods:{trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,onEsc(e){e.key==="Escape"&&(this.announcementBusy||this.renameBusy||this.membersBusy||this.deleteBusy||this.requestClose())},onOverlayClick(e){Ze(e)&&(this.announcementBusy||this.renameBusy||this.membersBusy||this.deleteBusy||this.requestClose())},requestClose(){this.$emit("close")},selectSection(e){e!==this.section&&(this.section=e)},async saveAnnouncement(){if(!(this.announcementBusy||!this.chat)){this.announcementBusy=!0,this.announcementError="";try{let e=await this.chat.sessionCrudRequest("update",{sessionId:this.groupId,patch:{announcement:this.announcementDraft}},{agentId:this.targetAgentId});if(!e||!e.ok){let t=e&&e.error&&e.error.code||"unknown",s=e&&e.error&&e.error.message||t;this.announcementError=this.$t("yeaft.session.announcement.saveFailed",{error:s})}}finally{this.announcementBusy=!1}}},async saveRename(){let e=(this.renameDraft||"").trim();if(!(!e||this.renameBusy||!this.chat)){this.renameBusy=!0,this.renameError="";try{let t=await this.chat.sessionCrudRequest("rename",{sessionId:this.groupId,name:e},{agentId:this.targetAgentId});if(!t||!t.ok){let s=t&&t.error&&t.error.code||"unknown",n=t&&t.error&&t.error.message||s;this.renameError=this.$t("yeaft.session.error.unknown",{message:n})}}finally{this.renameBusy=!1}}},isMember(e){return this.roster.includes(e)},vpLabelFor(e){let t=this.vpStore?.vpLabel;return typeof t=="function"?t(e):e},vpDescriptionFor(e){let t=this.vpStore?.vpDescription;return typeof t=="function"?t(e):""},vpTextColorFor(e){let t=this.vpStore?.vpTextColor;return typeof t=="function"?t(e):"var(--vp-avatar-rat-fg)"},async toggleMember(e,t){if(!(this.membersBusy||!this.chat)){this.membersBusy=!0,this.membersError="";try{let s=t?"add_member":"remove_member",n=await this.chat.sessionCrudRequest(s,{sessionId:this.groupId,vpId:e},{agentId:this.targetAgentId});if(!n||!n.ok){let r=n&&n.error&&n.error.code||"unknown",i=n&&n.error&&n.error.message||r;this.membersError=this.$t("yeaft.session.members.actionFailed",{error:i})}else if(s==="add_member"&&!this.defaultVpId){let r=await this.chat.sessionCrudRequest("set_default_vp",{sessionId:this.groupId,vpId:e},{agentId:this.targetAgentId});if(r&&!r.ok){let i=r.error&&r.error.code||"unknown",o=r.error&&r.error.message||i;this.membersError=this.$t("yeaft.session.members.actionFailed",{error:o})}}}finally{this.membersBusy=!1}}},async setDefault(e){if(!(this.membersBusy||!this.chat||this.defaultVpId===e)){this.membersBusy=!0,this.membersError="";try{let t=await this.chat.sessionCrudRequest("set_default_vp",{sessionId:this.groupId,vpId:e},{agentId:this.targetAgentId});if(!t||!t.ok){let s=t&&t.error&&t.error.code||"unknown",n=t&&t.error&&t.error.message||s;this.membersError=this.$t("yeaft.session.members.actionFailed",{error:n})}}finally{this.membersBusy=!1}}},runDream(){!this.vpStore||this.dreamRunning||this.vpStore.triggerGroupDream(this.groupId,{agentId:this.targetAgentId})},formatDreamTimestamp(e){if(!e)return"";try{return new Date(e).toLocaleString()}catch{return""}},async confirmDelete(){if(!(!this.deleteConfirmReady||this.deleteBusy||!this.chat)){this.deleteBusy=!0,this.deleteError="";try{let e=await this.chat.sessionCrudRequest("delete",{sessionId:this.groupId},{agentId:this.targetAgentId});if(!e||!e.ok){let t=e&&e.error&&e.error.code||"unknown",s=e&&e.error&&e.error.message||t;this.deleteError=this.$t("yeaft.session.error.unknown",{message:s});return}this.requestClose()}finally{this.deleteBusy=!1}}}},template:`
|
|
6838
6833
|
<Teleport to="body">
|
|
6839
6834
|
<div
|
|
6840
6835
|
class="group-settings-overlay"
|
|
@@ -7048,13 +7043,13 @@ ${String(e||"").trim()}
|
|
|
7048
7043
|
</div>
|
|
7049
7044
|
</div>
|
|
7050
7045
|
</Teleport>
|
|
7051
|
-
`}});function
|
|
7052
|
-
`).includes(s)):Array.isArray(e)?e:[]}function wg({latest:e={},snapshots:t={},promptLoads:s={},events:n=[],sessionTitles:r={}}={}){let i=new Set([...Object.keys(e||{}),...Object.keys(t||{}),...Object.keys(s||{})]);for(let o of Array.isArray(n)?n:[])o?.scope&&i.add(o.scope);return Array.from(i).map(o=>{let a=t?.[o]||null,l=e?.[o]||null,c=a?.lastError||l?.error||null,d=l?.status||(c?"error":a?.hasOutput?"completed":"never-ran"),u=s?.[o]||null,f=(Array.isArray(n)?n:[]).filter(y=>y?.scope===o),p=f[f.length-1]||null,g=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",b=
|
|
7046
|
+
`}});function Sy(e){let t=String(e||"").trim();return t?t.startsWith("[")&&t.endsWith("]")?hg(t.slice(1,-1)).map(s=>s.trim().replace(/^["']|["']$/g,"")).map(s=>vg(s)).filter(Boolean):hg(t).map(s=>vg(s.trim())).filter(Boolean):[]}function hg(e){let t=[],s="",n=0,r="",i=!1;for(let o of String(e||"")){if(i){s+=o,i=!1;continue}if(o==="\\"&&r){s+=o,i=!0;continue}if(r){s+=o,o===r&&(r="");continue}if(o==='"'||o==="'"){r=o,s+=o;continue}if((o==="{"||o==="[")&&(n+=1),(o==="}"||o==="]")&&n>0&&(n-=1),o===","&&n===0){s.trim()&&t.push(s.trim()),s="";continue}s+=o}return s.trim()&&t.push(s.trim()),t}function vg(e){let t=String(e||"").trim();if(!t||t==="[object Object]")return"";if(t.startsWith("{")&&t.endsWith("}"))try{let s=JSON.parse(t);return String(s.id||s.messageId||s.uuid||"").trim()}catch{return""}return t}function Iy(e){let t={},s=String(e||"").split(/\r?\n/);for(let n of s){let r=n.match(/^([A-Za-z][A-Za-z0-9_-]*):\s*(.*)$/);if(!r)continue;let i=r[1],o=r[2].trim();i==="tags"||i==="sourceMessages"?t[i]=Sy(o):t[i]=o.replace(/^["']|["']$/g,"")}return t}function Cy(e){let t=String(e||"").trim();if(!t)return[];let s=[],n=/(?:^|\n)---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*?)(?=\n---\s*\n|$)/g;for(let r of t.matchAll(n)){let i=r[1].trim(),o=r[2].trim(),a=Iy(i);s.push({id:a.id||`segment-${s.length+1}`,scope:a.scope||"",kind:a.kind||"memory",tags:Array.isArray(a.tags)?a.tags:[],sourceMessages:Array.isArray(a.sourceMessages)?a.sourceMessages:[],createdAt:a.createdAt||"",updatedAt:a.updatedAt||"",content:o,preview:tn(o,180)})}return s.length?s:[{id:"memory-1",scope:"",kind:"raw",tags:[],sourceMessages:[],createdAt:"",updatedAt:"",content:t,preview:tn(t,180)}]}function tn(e,t=160){let s=String(e||"").replace(/\s+/g," ").trim();return s.length<=t?s:`${s.slice(0,t).trim()}...`}function Ay(e){let t=String(e||"").trim();return t?(t.split(/\r?\n/).map(n=>n.trim()).find(Boolean)||"").replace(/^#+\s*/,"").replace(/^[-*]\s*/,"").trim():""}function xy(e){return String(e||"").replace(/\s+/g," ").trim()}function yg(e,t){return t?.sessionId||String(e||"").replace(/^sessions\//,"")}function Ty(e,t,s){let n=yg(e,t);return xy(s?.[e]||s?.[n]||t?.sessionTitle||t?.title||t?.name||Ay(t?.summaryText))||n||e}function bg(e,t){let s=String(t||"").trim().toLowerCase();return s?(Array.isArray(e)?e:[]).filter(n=>[n.title,n.scope,n.sessionId,n.status,n.summaryPreview,n.snapshot?.summaryText].map(i=>String(i||"").toLowerCase()).join(`
|
|
7047
|
+
`).includes(s)):Array.isArray(e)?e:[]}function wg({latest:e={},snapshots:t={},promptLoads:s={},events:n=[],sessionTitles:r={}}={}){let i=new Set([...Object.keys(e||{}),...Object.keys(t||{}),...Object.keys(s||{})]);for(let o of Array.isArray(n)?n:[])o?.scope&&i.add(o.scope);return Array.from(i).map(o=>{let a=t?.[o]||null,l=e?.[o]||null,c=a?.lastError||l?.error||null,d=l?.status||(c?"error":a?.hasOutput?"completed":"never-ran"),u=s?.[o]||null,f=(Array.isArray(n)?n:[]).filter(y=>y?.scope===o),p=f[f.length-1]||null,g=l?.finishedAt||l?.startedAt||a?.lastDreamAt||p?.at||a?.loadedAt||"",b=Cy(a?.memoryText||""),h=yg(o,a),A=Ty(o,a,r),w=c?tn(c.message||c.error||c.raw||"",180):"",S=tn(w||a?.summaryText||a?.memoryText||p?.detail||"",180);return{key:o,title:A,scope:o,sessionId:h,status:d,lastAt:g,latestRun:l,snapshot:a,lastError:c,promptLoad:u,events:f,segmentCount:b.length,segments:b,summaryPreview:S,subtitle:S,hasRequestResponse:f.some(y=>y?.request||y?.response||y?.systemPrompt||y?.rawRequest||y?.rawResponse)}}).sort((o,a)=>String(a.lastAt||"").localeCompare(String(o.lastAt||"")))}var kg=F(()=>{});var Oi,My,Sg,Ig=F(()=>{kg();Vo();Oi=1,My=5,Sg={name:"YeaftDebugPanel",emits:["close"],data(){return{expandedTurns:{},expandedLoops:{},expandedSections:{},expandedToolDetails:{},copiedFlash:null,copiedFlashAt:0,_expandSnapshot:null,dreamExpanded:!1,expandedDreamEvents:{},expandedDreamSegments:{},activeDreamItemKey:null,dreamItemSearch:"",activeTab:"requests"}},watch:{searchQuery(e,t){let s=!!(t&&t.trim()),n=!!(e&&e.trim());if(!s&&n){this._expandSnapshot={turns:{...this.expandedTurns},loops:{...this.expandedLoops}};let r={},i={};for(let o of this.turns)r[o.turnId]=!0,o.loops&&o.loops.length>0&&(i[`${o.turnId}#${o.loops[0].loopNumber}`]=!0);this.expandedTurns=r,this.expandedLoops=i}else if(s&&!n&&this._expandSnapshot)this.expandedTurns=this._expandSnapshot.turns,this.expandedLoops=this._expandSnapshot.loops,this._expandSnapshot=null;else if(n){let r={...this.expandedTurns};for(let i of this.turns)r[i.turnId]===void 0&&(r[i.turnId]=!0);this.expandedTurns=r}},"store.currentAgent"(e,t){e&&e!==t&&this.store&&typeof this.store.loadYeaftDebugHistory=="function"&&this.store.loadYeaftDebugHistory({limit:Oi,dreamLimit:5,indexOnly:!0})}},computed:{store(){return window.Pinia?.useChatStore?.()||null},sessionsStore(){return window.Pinia?.useSessionsStore?.()||null},turns(){return(this.store&&this.store.yeaftDebugTurnsForActiveSession||[]).map(t=>this.decorateTurnTokenBreakdowns(t))},searchQuery:{get(){return this.store&&this.store.yeaftDebugSearch||""},set(e){this.store&&this.store.setYeaftDebugSearch(e)}},sessionFilter:{get(){if(!this.store)return"";let e=this.store.yeaftDebugSessionFilter;return e??""},set(e){this.store&&(e?this.store.setYeaftDebugSessionFilter(e):this.store.setYeaftDebugSessionFilter(null))}},availableSessions(){return this.store&&this.store.yeaftDebugAvailableSessions||[]},turnTotal(){return this.store&&this.store.yeaftDebugTurnTotal||0},showingMatchedHint(){return this.turnTotal>this.turns.length},requestHistoryLoading(){return!!this.store?.yeaftDebugHistoryLoading},requestHistoryError(){return this.store?.yeaftDebugHistoryError||""},toolStats(){return this.store?.yeaftToolStats||null},toolStatsLoading(){return!!this.store?.yeaftToolStatsLoading},rankedToolRows(){let e=this.toolStats?.snapshot||{},t=Object.entries(e).map(([r,i])=>({name:r,...i})),s=new Set(t.map(r=>r.name)),n=Array.isArray(this.toolStats?.registered)?this.toolStats.registered:[];for(let r of n)typeof r!="string"||!r||s.has(r)||(t.push({name:r,callCount:0,errorCount:0,errorRate:0,avgMs:0,p50Ms:0,p95Ms:0,lastCalledAt:null,lastError:null}),s.add(r));return t.sort((r,i)=>{let o=(i.callCount||0)-(r.callCount||0);return o!==0?o:r.name.localeCompare(i.name)}),t},unusedToolRows(){return Array.isArray(this.toolStats?.unused)?this.toolStats.unused:[]},toolStatsFetchedAtLabel(){let e=this.toolStats?.fetchedAt;if(!e)return"";try{return new Date(e).toLocaleTimeString()}catch{return""}},dreamLatest(){return this.store&&this.store.yeaftDreamLatestForActiveSession||null},dreamLatestLabel(){let e=this.dreamLatest;if(!e)return"";if(e.status==="running")return`running \xB7 ${e.phase||"..."}`;if(e.status==="error")return`error \xB7 ${e.error||"unknown"}`;if(e.status==="skipped")return"skipped";let t=["done"];typeof e.mergedCount=="number"&&t.push(`merged ${e.mergedCount}`);let s=this.formatDreamMetrics(e);return s&&t.push(s),t.join(" \xB7 ")},dreamLatestKindLabel(){let e=this.dreamLatest;return e?e.manual?"manual":"auto":""},dreamSnapshot(){return this.store&&this.store.yeaftDreamSnapshotForActiveSession||null},dreamPromptLoad(){return this.store&&this.store.yeaftDreamPromptLoadForActiveSession||null},dreamPromptLoadSummary(){let e=this.dreamPromptLoad,t=e&&typeof e.summary=="string"?e.summary.trim():"";return t&&e.truncated?`${t}
|
|
7053
7048
|
... truncated`:t},dreamSnapshotSummary(){let e=this.dreamSnapshot,t=e&&typeof e.summaryText=="string"?e.summaryText.trim():"";return t&&e.summaryTruncated?`${t}
|
|
7054
7049
|
... truncated`:t},dreamSnapshotMemory(){let e=this.dreamSnapshot,t=e&&typeof e.memoryText=="string"?e.memoryText.trim():"";return t&&e.memoryTruncated?`${t}
|
|
7055
7050
|
... truncated`:t},dreamEvents(){let e=this.store&&this.store.yeaftDreamEventsForActiveSession||[];return Array.isArray(e)?e:[]},dreamEventCount(){return this.dreamEvents.length},dreamSessionTitles(){let e={},t=(r,i)=>{let o=String(i||"").trim();r&&o&&(e[r]=o)},s=this.sessionsStore?.sessions||{};for(let r of Object.values(s))!r||!r.id||(t(r.id,r.name||r.title),t(`sessions/${r.id}`,r.name||r.title));let n=this.store?.yeaftActiveSessionFilter;return n&&t(n,this.store?.yeaftActiveSessionName||this.store?.currentSessionTitle),e},allDreamItems(){let e=this.store||{},t=e.yeaftDreamEvents||{},s=Object.values(t).flatMap(n=>Array.isArray(n)?n:[]);return wg({latest:e.yeaftDreamLatest||{},snapshots:e.yeaftDreamSnapshots||{},promptLoads:e.yeaftDreamPromptLoads||{},events:s,sessionTitles:this.dreamSessionTitles})},dreamItems(){return bg(this.allDreamItems,this.dreamItemSearch)},activeDreamItem(){return this.activeDreamItemKey&&this.dreamItems.find(e=>e.key===this.activeDreamItemKey)||null},activeDreamRequestEvents(){let e=this.activeDreamItem;return e?e.events.filter(t=>t&&(t.request||t.response||t.rawRequest||t.rawResponse||t.systemPrompt||this.dreamLoopUserContent(t))):[]}},mounted(){this.store&&typeof this.store.loadYeaftDebugHistory=="function"&&this.store.loadYeaftDebugHistory({limit:Oi,dreamLimit:5,indexOnly:!0})},methods:{debugSessionId(e){return this.formatDebugSessionId(e&&(e.sessionId||e.groupId)||"")},debugDreamSessionId(e){return this.formatDebugSessionId(e&&(e.sessionId||e.groupId)||"")},formatDebugSessionId(e){let t=String(e||"");return t.startsWith("grp_")?t.slice(4):t},toggleTurn(e){let t=!this.expandedTurns[e];this.expandedTurns={...this.expandedTurns,[e]:t},t&&this.ensureRequestDetailLoaded(e)},debugLoopsForTurn(e){return(Array.isArray(this.store?.yeaftDebugLoops)?this.store.yeaftDebugLoops:[]).filter(s=>s&&s.turnId===e)},debugTurnNeedsDetailLoad(e){if(!e||!e.turnId)return!1;if(!e.detailsLoaded)return!0;let t=this.debugLoopsForTurn(e.turnId),s=Math.max(0,Number(e.loopCount||0)),n=new Set;for(let i of t){let o=Number(i?.loopNumber||0);Number.isFinite(o)&&o>0&&n.add(o)}if((n.size>0?Math.max(...n):0)>n.size||s>t.length)return!0;for(let i=1;i<=s;i++)if(!n.has(i))return!0;return!1},ensureRequestDetailLoaded(e){let t=this.store?.yeaftDebugTurnsById?.[e];!t||!this.store||typeof this.store.loadYeaftDebugHistory!="function"||this.debugTurnNeedsDetailLoad(t)&&this.store.loadYeaftDebugHistory({limit:Oi,dreamLimit:0,detailTurnId:e,groupId:t.sessionId||null})},toggleDream(){this.dreamExpanded=!this.dreamExpanded},dreamEventDetail(e){if(!e)return"";let t=e.phase||"unknown",s=[],n=!0;if(t==="start")s.push(e.manual?"manual trigger":"auto trigger");else if(t==="load-diff")this.debugDreamSessionId(e)&&s.push(`session ${this.debugDreamSessionId(e)}`);else if(t==="triage")typeof e.segments=="number"&&s.push(`${e.segments} segs`),typeof e.actions=="number"&&s.push(`${e.actions} actions`),e.status&&s.push(e.status);else if(t==="merge")typeof e.targets=="number"&&s.push(`${e.targets} targets`);else if(t==="apply")e.target&&s.push(e.target),e.status&&s.push(e.status),typeof e.mergedCount=="number"&&s.push(`merged ${e.mergedCount}`);else if(t==="done"){let r=typeof e.sessions=="number"?e.sessions:e.groups;typeof r=="number"&&s.push(`${r} sessions`),typeof e.targets=="number"&&s.push(`${e.targets} targets`),typeof e.duration=="number"&&s.push(this.formatMs(e.duration))}else t==="result"?(s.push(e.success?"success":"error"),typeof e.entriesCreated=="number"&&s.push(`entries ${e.entriesCreated}`),this.formatDreamMetrics(e)&&s.push(this.formatDreamMetrics(e)),!e.success&&e.error&&s.push(e.error),e.skipped&&s.push(`skipped: ${e.skippedReason||"unknown"}`)):n=!1;if(!n||s.length===0){let r=new Set(["type","phase","sessionId","groupId","target","ts","at"]);for(let[i,o]of Object.entries(e))r.has(i)||o!=null&&typeof o!="object"&&s.push(`${i}=${o}`)}return e.error&&!s.includes(e.error)&&s.unshift(`error: ${e.error}`),s.join(" \xB7 ")},dreamEventStatus(e){return e?e.status==="skipped"||e.skipped?"skipped":e.status==="error"||e.phase==="error"?"error":e.status==="done"||e.status==="success"||e.phase==="done"?"success":e.phase==="result"?e.success?"success":"error":"running":"running"},dreamEventTrigger(e){return e?e.trigger?e.trigger:e.source?e.source:e.manual===!0?"manual":e.manual===!1?"auto":"-":"-"},dreamEventCall(e){if(!e)return"-";let t=e.phase||"unknown",s=e.status||"";return t==="start"?"scheduler -> runDream":t==="load-diff"?"runDream -> loadSessionDiff":t==="triage"?s?`triageSessionSegments \xB7 ${s}`:"triageSessionSegments":t==="merge"?"mergeByTarget":t==="apply"?s?`applyMergedTarget \xB7 ${s}`:"applyMergedTarget":t==="done"?"runDream completed":t==="result"?"web-bridge -> yeaft_dream_result":t},dreamEventLocation(e){return e?e.target?e.target:e.scope?e.scope:this.debugDreamSessionId(e)?`session/${this.debugDreamSessionId(e)}`:e.vpId?`vp/${e.vpId}`:"-":"-"},dreamEventResult(e){if(!e)return"-";let t=[];return e.skipped&&t.push(`skipped: ${e.skippedReason||"unknown"}`),e.reason&&t.push(`reason: ${e.reason}`),typeof e.entriesCreated=="number"&&t.push(`entries ${e.entriesCreated}`),typeof e.targetsApplied=="number"&&t.push(`applied ${e.targetsApplied}`),typeof e.sessionsProcessed=="number"&&t.push(`sessions ${e.sessionsProcessed}`),typeof e.sessionsSkipped=="number"&&t.push(`skipped sessions ${e.sessionsSkipped}`),typeof e.segments=="number"&&t.push(`segments ${e.segments}`),typeof e.actions=="number"&&t.push(`actions ${e.actions}`),typeof e.targets=="number"&&t.push(`targets ${e.targets}`),typeof e.duration=="number"&&t.push(this.formatMs(e.duration)),this.formatDreamMetrics(e)&&t.push(this.formatDreamMetrics(e)),Array.isArray(e.targetErrors)&&e.targetErrors.length>0&&t.push(`errors ${e.targetErrors.length}: ${this.truncate(e.targetErrors.map(s=>s.target?`${s.target}: ${s.error}`:s.error).join("; "),160)}`),e.error&&t.push(`error: ${e.error}`),t.length>0?t.join(" \xB7 "):this.dreamEventDetail(e)},dreamEventKind(e){if(!e)return"progress";let t=e.type;return t==="loop"?"loop":t==="turn_close"||t==="dream_turn_close"?"turn_close":t==="dream_run"&&e.phase==="result"?"result":"progress"},isDreamEventExpandable(e){let t=this.dreamEventKind(e);return t==="loop"?!!(e&&(e.systemPrompt||e.response||Array.isArray(e.messages)&&e.messages.length>0)):t==="turn_close"||t==="result"?!!(e&&(e.metrics||e.passBreakdown||e.resultSummary)):t==="progress"?!!(e&&(e.memoryMdPreview||e.summaryMdPreview)):!1},dreamEventKey(e){return e?`${e.at||0}:${e.turnId||""}:${e.phase||e.type||""}`:""},toggleDreamEvent(e){let t=this.dreamEventKey(e);if(!t)return;let s=new Set(this.dreamEvents.map(r=>this.dreamEventKey(r))),n={};for(let[r,i]of Object.entries(this.expandedDreamEvents))s.has(r)&&(n[r]=i);n[t]=!n[t],this.expandedDreamEvents=n},isDreamEventExpanded(e){return!!this.expandedDreamEvents[this.dreamEventKey(e)]},dreamLoopUserContent(e){let t=Array.isArray(e?.messages)?e.messages:[];for(let s of t)if(s&&s.role==="user"){if(typeof s.content=="string")return s.content;if(s.content!=null)return JSON.stringify(s.content,null,2)}return""},formatPassBreakdown(e){if(!e||typeof e!="object")return"";let t=[];for(let[s,n]of Object.entries(e)){if(!n)continue;let r=[s+":"];n.llmCallCount&&r.push(`${n.llmCallCount} call`),n.totalTokens&&r.push(`${this.formatTokens(n.totalTokens)} tok`),n.durationMs&&r.push(this.formatMs(n.durationMs)),t.push(r.join(" "))}return t.join(" \xB7 ")},copyDreamEventAsMarkdown(e){if(!e)return;let t=this.dreamEventKind(e),s=[`# Dream event \xB7 ${t} \xB7 ${e.phase||e.type||"?"}`];if(s.push(`- at: ${this.formatTimestamp(e.at)}`),e.turnId&&s.push(`- turnId: ${e.turnId}`),this.debugDreamSessionId(e)&&s.push(`- sessionId: ${this.debugDreamSessionId(e)}`),e.target&&s.push(`- target: ${e.target}`),t==="loop"){s.push(`- pass: ${e.pass||"-"}`),s.push(`- model: ${e.model||"-"}`),s.push(`- latency: ${this.formatMs(e.latencyMs)}`);let n=e.usage||{};s.push(`- tokens: ${this.formatUsageBreakdown(n)}`),s.push("","## System prompt","```",e.systemPrompt||"","```"),s.push("","## User message","```",this.dreamLoopUserContent(e),"```"),s.push("","## Response","```",e.response||"","```")}else if(t==="turn_close"){s.push(`- loopCount: ${e.loopCount??e.metrics?.llmCallCount??0}`),s.push(`- totalTokens: ${e.totalTokens??e.metrics?.totalTokens??0}`),s.push(`- totalMs: ${e.totalMs??e.metrics?.durationMs??0}`);let n=e.passBreakdown||e.metrics?.passBreakdown;n&&s.push("","## Pass breakdown","```json",JSON.stringify(n,null,2),"```")}else t==="result"?(s.push(`- status: ${e.status||"-"}`),e.error&&s.push(`- error: ${e.error}`),e.resultSummary&&s.push("","## Result summary","```json",JSON.stringify(e.resultSummary,null,2),"```"),e.metrics&&s.push("","## Metrics","```json",JSON.stringify(e.metrics,null,2),"```")):(e.memoryMdPreview&&s.push("","## memory.md (preview)","```",e.memoryMdPreview,"```"),e.summaryMdPreview&&s.push("","## summary.md (preview)","```",e.summaryMdPreview,"```"),!e.memoryMdPreview&&!e.summaryMdPreview&&s.push("","## Raw","```json",JSON.stringify(e,null,2),"```"));this.copyText(s.join(`
|
|
7056
7051
|
`),"dream event")},toggleLoop(e,t){let s=`${e}#${t}`;this.expandedLoops={...this.expandedLoops,[s]:!this.expandedLoops[s]}},toggleSection(e,t){let s=`${e}#${t}`;this.expandedSections={...this.expandedSections,[s]:!this.expandedSections[s]}},isLoopExpanded(e,t){return!!this.expandedLoops[`${e}#${t}`]},isSectionExpanded(e,t){return!!this.expandedSections[`${e}#${t}`]},formatMs(e){return e==null?"-":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`},formatTokens(e){let t=Number(e)||0;return t>=1e3?`${(t/1e3).toFixed(1)}k`:String(t)},usageTotalInputTokens(e){let t=e||{};return Number.isFinite(Number(t.totalInputTokens))?Number(t.totalInputTokens):(Number(t.inputTokens)||0)+(Number(t.cacheReadTokens)||0)+(Number(t.cacheWriteTokens)||0)},usageTotalTokens(e){let t=e||{};return Number.isFinite(Number(t.totalTokens))?Number(t.totalTokens):this.usageTotalInputTokens(t)+(Number(t.outputTokens)||0)},formatUsageBreakdown(e){let t=e||{},s=Number(t.cacheReadTokens)||0,n=Number(t.cacheWriteTokens)||0,r=this.usageTotalInputTokens(t),i=Number(t.outputTokens)||0,o=this.usageTotalTokens(t),a=`${r} in / ${i} out / ${o} total`;return(s||n)&&(r===(Number(t.inputTokens)||0)?a+=` (input includes cache read ${s}, cache write ${n})`:a+=` (fresh ${Number(t.inputTokens)||0}, cache read ${s}, cache write ${n})`),a},formatDreamMetrics(e){if(!e)return"";let t=[];return typeof e.durationMs=="number"&&t.push(this.formatMs(e.durationMs)),typeof e.llmCallCount=="number"&&t.push(`${e.llmCallCount} LLM calls`),typeof e.totalTokens=="number"&&t.push(`${this.formatTokens(e.totalTokens)} tok`),t.join(" \xB7 ")},formatTimestamp(e){if(!e)return"";try{return new Date(e).toLocaleTimeString()}catch{return""}},formatClock(e){return Hc(e)},loopClockTime(e,t){if(t&&typeof t.at=="number")return this.formatClock(t.at);if(!e||typeof e.openedAt!="number")return"";let s=e.loops||[],n=0;for(let r of s)if(r){if(r===t||r.loopNumber===t.loopNumber)break;Number.isFinite(r.latencyMs)&&(n+=r.latencyMs)}return Number.isFinite(t.latencyMs)&&(n+=t.latencyMs),this.formatClock(e.openedAt+n)},loopTokenBreakdown(e){if(!e)return{inputMessage:0,inputTool:0,outputMessage:0,outputTool:0,inputTotal:0,outputTotal:0,total:0};let t=Oc(e),s=e.usage||{},n=Math.max(0,this.usageTotalInputTokens(s)),r=Math.max(0,Number(s.outputTokens)||0),i=Math.max(0,this.usageTotalTokens(s)||n+r),o=$o(n,t.inputMessageTokens,t.inputToolTokens),a=$o(r,t.outputMessageTokens,t.outputToolTokens);return{inputMessage:o.message,inputTool:o.tool,outputMessage:a.message,outputTool:a.tool,inputTotal:n,outputTotal:r,total:i}},decorateTurnTokenBreakdowns(e){if(!e)return e;let t={inputMessage:0,inputTool:0,outputMessage:0,outputTool:0,inputTotal:0,outputTotal:0,total:0},s=(e&&e.loops||[]).map(o=>{let a=this.loopTokenBreakdown(o);return t.inputMessage+=a.inputMessage,t.inputTool+=a.inputTool,t.outputMessage+=a.outputMessage,t.outputTool+=a.outputTool,t.inputTotal+=a.inputTotal,t.outputTotal+=a.outputTotal,t.total+=a.total,{...o,tokenBreakdown:a}});s.length===0&&(t.inputTotal=Math.max(0,Number(e.summaryInputTokens)||0),t.outputTotal=Math.max(0,Number(e.summaryOutputTokens)||0),t.total=t.inputTotal+t.outputTotal);let n=s.reduce((o,a)=>(Number(a?.tokenBreakdown?.total)||0)>(Number(o?.tokenBreakdown?.total)||0)?a:o,null),r={...t,messageTotal:t.inputMessage+t.outputMessage,toolTotal:t.inputTool+t.outputTool},i=Math.max(Number(e.totalTokens)||0,r.total||0);if(i>r.total){let o=i-r.total;r.total=i,r.inputTotal+=o,r.inputMessage+=o,r.messageTotal+=o}return{...e,loops:s,tokenBreakdown:r,maxLoopTokenBreakdown:n?.tokenBreakdown||null,maxLoopTokenTotal:Number(n?.tokenBreakdown?.total)||0,maxLoopNumber:n?.loopNumber||null}},turnTotalTokens(e){return Math.max(Number(e?.totalTokens)||0,Number(e?.tokenBreakdown?.total)||0)},loopBreakdownMessageTokens(e){return(Number(e?.inputMessage)||0)+(Number(e?.outputMessage)||0)},loopBreakdownToolTokens(e){return(Number(e?.inputTool)||0)+(Number(e?.outputTool)||0)},loopMessageTokens(e){return this.loopBreakdownMessageTokens(e?.tokenBreakdown||{})},loopToolTokens(e){return this.loopBreakdownToolTokens(e?.tokenBreakdown||{})},tokenPct(e,t){let s=Number(e)||0,n=Number(t)||0;return n<=0||s<=0?"0%":`${Math.round(s/n*100)}%`},tokenBreakdownTitle(e){let t=e||{},s=(Number(t.inputMessage)||0)+(Number(t.outputMessage)||0),n=(Number(t.inputTool)||0)+(Number(t.outputTool)||0),r=Math.max(Number(t.total)||0,s+n);return`estimated token split: message ${s} (${this.tokenPct(s,r)}), tool ${n} (${this.tokenPct(n,r)}); input ${Number(t.inputTotal)||0}, output ${Number(t.outputTotal)||0}, total ${r}`},truncate(e,t){let s=String(e||"");return s.length<=t?s:s.slice(0,t)+"\u2026"},toolsForLoop(e,t){let s=typeof t=="object"?t:(e?.loops||[]).find(l=>l&&l.loopNumber===t)||{loopNumber:t},n=s?.loopNumber||0,r=(e&&e.tools||[]).filter(l=>l&&l.loopNumber===n),i=new Set,o=Array.isArray(s?.toolCalls)?s.toolCalls:[],a=[];for(let l=0;l<o.length;l++){let c=o[l]||{},d=c.id||c.callId||c.tool_call_id||null,u=d?r.findIndex((p,g)=>!i.has(g)&&p.callId===d):-1;u<0&&(u=r.findIndex((p,g)=>!i.has(g)&&!p.callId&&p.name===c.name));let f=u>=0?r[u]:null;u>=0&&i.add(u),a.push(this.normalizeToolDebugRow(n,c,f,l))}for(let l=0;l<r.length;l++)i.has(l)||a.push(this.normalizeToolDebugRow(n,null,r[l],a.length));return a},normalizeToolDebugRow(e,t,s,n){let r=!!s,i=t&&Object.prototype.hasOwnProperty.call(t,"input")?t.input:void 0,o=t&&(t.id||t.callId||t.tool_call_id)||s?.callId||null,a=t&&t.name||s?.name||"?";return{loopNumber:e,index:n,callId:o,name:a,input:i,rawCall:t||null,rawResult:s||null,hasResult:r,isRunning:!r,isError:!!s?.isError,durationMs:s?.durationMs||0,toolOutput:s?.toolOutput==null?null:String(s.toolOutput)}},toolDetailKey(e,t,s,n=0){return`${e}#${t}#${s?.callId||s?.name||"tool"}#${n}`},isToolDetailExpanded(e,t,s,n){return!!this.expandedToolDetails[this.toolDetailKey(e,t,s,n)]},toggleToolDetail(e,t,s,n){let r=this.toolDetailKey(e,t,s,n);this.expandedToolDetails={...this.expandedToolDetails,[r]:!this.expandedToolDetails[r]}},toolStatusClass(e){return e?.isRunning?"running":e?.isError?"err":"ok"},toolStatusLabel(e){return e?.isRunning?this.$t?this.$t("yeaft.debugToolRunning"):"running":e?.isError?"\u2717":"\u2713"},toolInputText(e){return e?e.input!==void 0?JSON.stringify(e.input??null,null,2):e.rawCall?JSON.stringify(e.rawCall,null,2):JSON.stringify(e.rawResult||e,null,2):""},toolOutputText(e){return e?e.isRunning?this.$t?this.$t("yeaft.debugToolRunningNoResult"):"Running; no result yet":e.toolOutput!=null?e.toolOutput:e.rawResult?JSON.stringify(e.rawResult,null,2):"":""},reflectionsForLoop(e,t){return(e&&e.reflections||[]).filter(n=>n&&(n.loopNumber===t||n.loopNumber==null&&t===e.loopCount))},loopMetaSummary(e){let t=(e.toolCalls||[]).length;return t>0?`tools\xD7${t}`:"end_turn"},assistantResponseForLoop(e){if(!e)return"";if(e.response)return typeof e.response=="string"?e.response:JSON.stringify(e.response,null,2);let t=Array.isArray(e.messages)?e.messages:[];for(let s=t.length-1;s>=0;s--){let n=t[s];if(!(!n||n.role!=="assistant")){if(typeof n.content=="string")return n.content;if(Array.isArray(n.content)){let r=n.content.map(i=>i?typeof i=="string"?i:typeof i.text=="string"?i.text:"":"").filter(Boolean);if(r.length>0)return r.join(`
|
|
7057
|
-
`)}if(n.content!=null)return JSON.stringify(n.content,null,2)}}return""},showAssistantResponse(e,t){let s=`${e}#${t}`,n=`${e}#asst-${t}`;this.expandedLoops={...this.expandedLoops,[s]:!0},this.expandedSections={...this.expandedSections,[n]:!0}},setActiveDreamItem(e){this.activeDreamItemKey=this.activeDreamItemKey===e?null:e||null},isDreamSegmentExpanded(e){return!!this.expandedDreamSegments[e?.id]},toggleDreamSegment(e){e?.id&&(this.expandedDreamSegments={...this.expandedDreamSegments,[e.id]:!this.expandedDreamSegments[e.id]})},dreamPreview(e,t=180){return tn(e,t)},formatDebugValue(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)},setActiveTab(e){this.activeTab=e==="toolStats"||e==="dream"?e:"requests",this.activeTab==="toolStats"&&!this.toolStats&&!this.toolStatsLoading&&this.refreshToolStats(),this.activeTab==="requests"&&this.turns.length===0&&!this.requestHistoryLoading&&this.loadRequestHistory()},loadRequestHistory(){if(!this.store||typeof this.store.loadYeaftDebugHistory!="function")return;let e=String(this.searchQuery||"").trim();this.store.loadYeaftDebugHistory({limit:e?
|
|
7052
|
+
`)}if(n.content!=null)return JSON.stringify(n.content,null,2)}}return""},showAssistantResponse(e,t){let s=`${e}#${t}`,n=`${e}#asst-${t}`;this.expandedLoops={...this.expandedLoops,[s]:!0},this.expandedSections={...this.expandedSections,[n]:!0}},setActiveDreamItem(e){this.activeDreamItemKey=this.activeDreamItemKey===e?null:e||null},isDreamSegmentExpanded(e){return!!this.expandedDreamSegments[e?.id]},toggleDreamSegment(e){e?.id&&(this.expandedDreamSegments={...this.expandedDreamSegments,[e.id]:!this.expandedDreamSegments[e.id]})},dreamPreview(e,t=180){return tn(e,t)},formatDebugValue(e){return e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2)},setActiveTab(e){this.activeTab=e==="toolStats"||e==="dream"?e:"requests",this.activeTab==="toolStats"&&!this.toolStats&&!this.toolStatsLoading&&this.refreshToolStats(),this.activeTab==="requests"&&this.turns.length===0&&!this.requestHistoryLoading&&this.loadRequestHistory()},loadRequestHistory(){if(!this.store||typeof this.store.loadYeaftDebugHistory!="function")return;let e=String(this.searchQuery||"").trim();this.store.loadYeaftDebugHistory({limit:e?My:Oi,dreamLimit:5,indexOnly:!0,search:e})},refreshToolStats(){this.store&&typeof this.store.fetchYeaftToolStats=="function"&&this.store.fetchYeaftToolStats()},formatPct(e){return!Number.isFinite(e)||e===0?"0%":`${(e*100).toFixed(1)}%`},formatLastCalled(e){if(typeof e!="string"||!e)return"never";let t=Date.parse(e);if(Number.isNaN(t))return e;let s=Date.now()-t;return s<6e4?"just now":s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:`${Math.floor(s/864e5)}d ago`},copyText(e,t){let s=e==null?"":typeof e=="string"?e:JSON.stringify(e,null,2);try{if(navigator&&navigator.clipboard&&navigator.clipboard.writeText)navigator.clipboard.writeText(s);else{let n=document.createElement("textarea");n.value=s,n.style.position="fixed",n.style.left="-9999px",document.body.appendChild(n),n.select();try{document.execCommand("copy")}catch{}document.body.removeChild(n)}this.copiedFlash=t||"copied",this.copiedFlashAt=Date.now(),setTimeout(()=>{Date.now()-this.copiedFlashAt>=1400&&(this.copiedFlash=null)},1500)}catch{}},copyToolInput(e,t){if(t&&(t.input!==void 0||t.rawCall||t.rawResult)){this.copyText(this.toolInputText(t),"tool input");return}for(let s of e.loops||[])for(let n of s.toolCalls||[])if(n&&n.id===t.callId){this.copyText(JSON.stringify(n.input??null,null,2),"tool input");return}this.copyText(JSON.stringify(t,null,2),"tool record")},copyRawRequest(e){this.copyText(this.rawRequestForLoop(e),"raw request")},rawRequestForLoop(e){return e?.rawRequest!=null?e.rawRequest:Fc(e?.rawRequestBase??e?.requestBase?.rawRequest??null,e?.requestDelta||null)},copyToolOutput(e,t){if(t&&(t.isRunning||t.rawResult||t.toolOutput!=null)){this.copyText(this.toolOutputText(t),"tool output");return}if(t&&t.toolOutput!=null){this.copyText(t.toolOutput,"tool output");return}for(let s of e.loops||[])for(let n of s.messages||[])if(n&&n.role==="tool"&&n.toolCallId===t.callId){this.copyText(typeof n.content=="string"?n.content:JSON.stringify(n.content,null,2),"tool output");return}this.copyText("(tool output not in snapshot)","tool output")},copyTurnAsMarkdown(e){let t=[];if(t.push(`# Turn ${e.turnId}`),t.push(""),t.push(`- VP: ${e.vpId||"-"}`),t.push(`- Session: ${this.debugSessionId(e)||"-"}`),t.push(`- Loops: ${e.loopCount||e.loops&&e.loops.length||0}`),t.push(`- Total: ${this.formatMs(e.totalMs)} / ${this.formatTokens(e.totalTokens)} tok`),t.push(""),t.push("## User prompt"),t.push(""),t.push("```"),t.push(e.userPrompt||""),t.push("```"),t.push(""),e.memoryLoaded&&e.memoryLoaded.length>0){t.push(`## Memory loaded (${e.memoryLoaded.length})`);for(let n of e.memoryLoaded)t.push(`- ${n.id||"?"} layer=${n.layer||"-"} score=${n.score==null?"-":n.score.toFixed(3)} kind=${n.kind||"-"} scope=${n.label||n.scope||"-"}`),n.body&&(t.push(""),t.push("```text"),t.push(n.body),t.push("```"));t.push("")}if(e.memoryAdjust){let n=e.memoryAdjust;t.push(`## Memory adjust (reason: ${n.reason||"-"})`),t.push(`- added: ${n.added||0}`),t.push(`- evicted: ${n.evicted||0}`),t.push(`- skipped: ${n.skipped||0}`),t.push("")}let s=e.loops||[];for(let n of s){t.push(`## Loop ${n.loopNumber} ${n.model}`);let r=n.usage||{};t.push(`- in/out/total: ${this.formatUsageBreakdown(r)}`),t.push(`- latency: ${this.formatMs(n.latencyMs)} ttfb: ${this.formatMs(n.ttfbMs)}`),t.push(`- stopReason: ${n.stopReason||"-"}`);let i=this.toolsForLoop(e,n.loopNumber);if(i.length>0){t.push(""),t.push(`### Tools (${i.length})`);for(let a of i){let l=a.isRunning?"running":a.isError?"ERROR":"ok";t.push(`- ${a.name} ${l} ${a.isRunning?"-":this.formatMs(a.durationMs)}`)}}let o=this.assistantResponseForLoop(n);o&&(t.push(""),t.push("### Assistant text"),t.push("```"),t.push(o),t.push("```")),t.push("")}this.copyText(t.join(`
|
|
7058
7053
|
`),"turn markdown")}},template:`
|
|
7059
7054
|
<div class="yeaft-debug-panel">
|
|
7060
7055
|
<div class="yeaft-debug-header">
|
|
@@ -7540,9 +7535,9 @@ ${String(e||"").trim()}
|
|
|
7540
7535
|
<span v-else>{{ requestHistoryLoading ? $t('yeaft.debugHistoryLoading') : $t('yeaft.noDebugData') }}</span>
|
|
7541
7536
|
</div>
|
|
7542
7537
|
</div>
|
|
7543
|
-
`}});function xg(e,t){if(!e||e.kind!=="sub_agent")return"";let s=typeof t=="function"?t:u=>u,n=typeof e.log?.preview=="string"?e.log.preview:"",r=[],i="",o="",a=0,l=()=>{let u=Ag(o);u&&r.push(s("yeaft.sessionStatus.task.subAgentEvent",{name:i||s("yeaft.sessionStatus.task.kind.subAgent"),text:u})),i="",o=""},c=()=>{i="",o=""};for(let u of n.split(/\r?\n/)){let f=
|
|
7544
|
-
`)}function
|
|
7545
|
-
`).filter(Boolean).filter(l=>!o.includes(l));return[...o,...a]}var
|
|
7538
|
+
`}});function xg(e,t){if(!e||e.kind!=="sub_agent")return"";let s=typeof t=="function"?t:u=>u,n=typeof e.log?.preview=="string"?e.log.preview:"",r=[],i="",o="",a=0,l=()=>{let u=Ag(o);u&&r.push(s("yeaft.sessionStatus.task.subAgentEvent",{name:i||s("yeaft.sessionStatus.task.kind.subAgent"),text:u})),i="",o=""},c=()=>{i="",o=""};for(let u of n.split(/\r?\n/)){let f=Py(u);if(f){if(f.type==="text_delta"){i=f.agentName||f.agentId||i,o+=f.text||f.content||f.delta||"";continue}if(f.type==="tool_use"||f.type==="tool_call"){a+=1;continue}if(f.type==="sub_agent_turn_end"){c();let p=Cg(f,s);p&&r.push(p);continue}if(f.type==="error"){l();let p=Cg(f,s);p&&r.push(p)}}}l();let d=_y(a,s);return d&&r.push(d),r.join(`
|
|
7539
|
+
`)}function Ey(e,t){if(!e||e.kind!=="sub_agent")return[];let s=typeof t=="function"?t:l=>l,n=Ry(e.result?.summary),r=s("yeaft.sessionStatus.task.kind.subAgent"),i=e.agentName||e.agentId||r,o=n?[s("yeaft.sessionStatus.task.subAgentResult",{name:i,text:n})]:[],a=xg(e,t).split(`
|
|
7540
|
+
`).filter(Boolean).filter(l=>!o.includes(l));return[...o,...a]}var Py,Ry,Ag,_y,Cg,Tg,Mg=F(()=>{xa();Py=e=>{if(typeof e!="string")return null;let t=e.trim();if(!t.startsWith("{")||!t.endsWith("}"))return null;try{return JSON.parse(t)}catch{return null}},Ry=(e,t=360)=>{if(typeof e!="string")return"";let s=e.trim().replace(/\s+/g," ");return s.length>t?s.slice(0,t-1)+"\u2026":s},Ag=e=>typeof e!="string"?"":e.trim(),_y=(e,t)=>{let s=Number(e||0);return!Number.isFinite(s)||s<=0?"":(typeof t=="function"?t:r=>r)("yeaft.sessionStatus.task.subAgentToolSummary",{count:s})},Cg=(e,t)=>{if(!e||typeof e!="object")return"";let s=typeof t=="function"?t:r=>r,n=e.agentName||e.agentId||s("yeaft.sessionStatus.task.kind.subAgent");if(e.type==="sub_agent_turn_end"){let r=Ag(e.content||e.text);return r?s("yeaft.sessionStatus.task.subAgentResult",{name:n,text:r}):""}if(e.type==="error"){let r=e.error&&(e.error.message||e.error);return r?s("yeaft.sessionStatus.task.subAgentError",{name:n,error:r}):s("yeaft.sessionStatus.task.subAgentHitError",{name:n})}return""};Tg={name:"VpTimelinePane",components:{TerminalOutput:si},emits:["mention-vp","edit-vp","start-resize","cancel-vp-turn","edit-announcement","cancel-task","close"],props:{rows:{type:Array,required:!0},tasks:{type:Array,default:()=>[]},announcementText:{type:String,default:""},stoppingTasksById:{type:Object,default:()=>({})}},template:`
|
|
7546
7541
|
<aside class="yeaft-vp-timeline yeaft-session-status-pane" :aria-label="$t('yeaft.sessionStatus.aria')">
|
|
7547
7542
|
<div
|
|
7548
7543
|
class="yeaft-vp-timeline-resize-handle"
|
|
@@ -7755,7 +7750,7 @@ ${String(e||"").trim()}
|
|
|
7755
7750
|
</section>
|
|
7756
7751
|
</aside>
|
|
7757
7752
|
`,setup(e,{emit:t}){let s=window.Pinia&&window.Pinia.useVpStore?window.Pinia.useVpStore():null,n=C=>s&&typeof s.vpTextColor=="function"?s.vpTextColor(C):"var(--text-primary)",r=Vue.getCurrentInstance(),i=r&&r.appContext.config.globalProperties.$t||(C=>C),o=Vue.computed(()=>(typeof e.announcementText=="string"?e.announcementText:"").trim()),a=Vue.computed(()=>!!o.value),l=Vue.computed(()=>{let C=o.value.replace(/\s+/g," ");return C.length<=96?C:C.slice(0,95)+"\u2026"}),c=Vue.ref({}),d=new Map,u=new Map,f=C=>{let R=d.get(C);R&&(R.scrollTop=R.scrollHeight,u.set(C,!0))},p=C=>{let R=!c.value[C];c.value={...c.value,[C]:R},R&&(u.set(C,!0),Vue.nextTick(()=>f(C)))},g=(C,R)=>{R?(d.set(C,R),u.has(C)||u.set(C,!0),Vue.nextTick(()=>{u.get(C)&&f(C)})):d.delete(C)},b=C=>{let R=d.get(C);if(!R)return;let B=R.scrollHeight-R.scrollTop-R.clientHeight;u.set(C,B<8)};Vue.watch(()=>JSON.stringify((Array.isArray(e.tasks)?e.tasks:[]).map(C=>[C.id,C?.log?.preview||""])),()=>Vue.nextTick(()=>{d.forEach((C,R)=>{u.get(R)&&f(R)})}));let h=C=>{let R=C?.ownerVpId||"";return R?s&&typeof s.vpLabel=="function"?s.vpLabel(R):R:"unknown"},A=C=>{if(!C)return"";try{return new Date(C).toLocaleTimeString()}catch{return String(C)}},w=C=>{switch(C?.kind){case"sub_agent":return i("yeaft.sessionStatus.task.kind.subAgent");case"shell":return i("yeaft.sessionStatus.task.kind.shell");default:return C?.kind||""}},S=C=>{let R=C?.runtime?.command;return typeof R=="string"?R.trim():""},y=C=>{let R=[],B=C?.title||C?.id||"",O=S(C);return B&&R.push(`${i("yeaft.sessionStatus.task.title")}: ${B}`),O&&R.push(`${i("yeaft.sessionStatus.task.command")}: ${O}`),R.join(`
|
|
7758
|
-
`)},m=C=>`${C?.agentId||""}${C?.sessionId||""}::${C?.id||""}`,v=C=>C?.kind==="shell"&&C?.status==="running"&&!!C?.runtime?.pid,E=C=>!!(C?.id&&e.stoppingTasksById?.[m(C)]),V=C=>
|
|
7753
|
+
`)},m=C=>`${C?.agentId||""}${C?.sessionId||""}::${C?.id||""}`,v=C=>C?.kind==="shell"&&C?.status==="running"&&!!C?.runtime?.pid,E=C=>!!(C?.id&&e.stoppingTasksById?.[m(C)]),V=C=>Ey(C,i),U=C=>xg(C,i),L=C=>{switch(C.status){case"idle":return i("yeaft.vpTimeline.status.idle");case"typing":return i("yeaft.vpTimeline.status.typing");case"thinking":return i("yeaft.vpTimeline.status.thinking");case"retrying":return i("yeaft.vpTimeline.status.retrying");case"streaming":return i("yeaft.vpTimeline.status.streaming");case"tool":return i("yeaft.vpTimeline.status.tool");case"error":return i("yeaft.vpTimeline.status.error");case"offline":return i("yeaft.vpTimeline.status.offline");default:return C.status}},D=new Set(["typing","thinking","retrying","streaming","tool"]);return{hasAnnouncement:a,announcementPreview:l,statusLabel:L,isActiveStatus:C=>D.has(C),threadCountTitle:C=>{let R=Array.isArray(C&&C.threads)?C.threads:[];return R.length?R.slice(0,5).map(B=>`${B.title||B.threadId||"thread"}: ${B.status||"idle"}`).join(`
|
|
7759
7754
|
`):""},vpTextColorFor:n,expandedTasks:c,toggleTaskExpanded:p,taskOwnerName:h,formatTaskTime:A,taskKindLabel:w,shellTaskCommand:S,taskSummaryTitle:y,isTaskCancellable:v,isTaskStopping:E,taskDetailLines:V,subAgentTaskStreamText:U,setTaskLogRef:g,onTaskLogScroll:b}}}});var Pg,Rg=F(()=>{Pg={name:"YeaftSessionActions",emits:["toggle-search","reload-messages","toggle-session-status","toggle-debug","reload-page"],props:{searchOpen:{type:Boolean,default:!1},loadingMoreHistory:{type:Boolean,default:!1},sessionStatusVisible:{type:Boolean,default:!0},debugMode:{type:Boolean,default:!1},showPageReload:{type:Boolean,default:!1}},template:`
|
|
7760
7755
|
<div class="yeaft-session-actions">
|
|
7761
7756
|
<button
|
|
@@ -7820,7 +7815,7 @@ ${String(e||"").trim()}
|
|
|
7820
7815
|
</svg>
|
|
7821
7816
|
</button>
|
|
7822
7817
|
</div>
|
|
7823
|
-
`}});function _g(e){let t=typeof e=="number"?e:Date.parse(e||"");return Number.isFinite(t)?t:null}function
|
|
7818
|
+
`}});function _g(e){let t=typeof e=="number"?e:Date.parse(e||"");return Number.isFinite(t)?t:null}function Dy(e){let t=_g(e);return t===null?"":new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(t))}function Ly(e){return(Array.isArray(e)?e:[]).map((t,s)=>({result:t,index:s,time:_g(t?.timestamp),seq:Number.isFinite(t?.seq)?t.seq:null,messageId:String(t?.messageId||"")})).sort((t,s)=>t.time!==null&&s.time===null?-1:t.time===null&&s.time!==null?1:t.time!==null&&t.time!==s.time?s.time-t.time:t.seq!==null&&s.seq===null?-1:t.seq===null&&s.seq!==null?1:t.seq!==null&&t.seq!==s.seq?s.seq-t.seq:s.messageId.localeCompare(t.messageId)||t.index-s.index).map(({result:t})=>t)}var Eg,Dg=F(()=>{Ci();Eg={name:"YeaftConversationOutline",components:{ModernSelect:Js},props:{outlineState:{type:Object,required:!0},searchState:{type:Object,required:!0},senderOptions:{type:Array,default:()=>[]},activeMessageId:{type:String,default:null}},emits:["query","sender","sender-invalid","select","move","preview","load-older","load-more-search","close"],computed:{senderSelectOptions(){return[{value:"",label:this.$t("yeaft.outline.allSenders")},...this.senderOptions.map(e=>({value:e.key,label:e.label}))]}},template:`
|
|
7824
7819
|
<section id="yeaft-conversation-outline" class="yeaft-conversation-outline" :aria-label="$t('yeaft.outline.label')">
|
|
7825
7820
|
<div class="yeaft-conversation-outline-header">
|
|
7826
7821
|
<div>
|
|
@@ -7896,7 +7891,7 @@ ${String(e||"").trim()}
|
|
|
7896
7891
|
>{{ $t('yeaft.outline.moreMatches') }}</button>
|
|
7897
7892
|
</div>
|
|
7898
7893
|
</section>
|
|
7899
|
-
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=Vue.computed(()=>String(e.searchState.query||"").trim().length>=2||!!e.searchState.senderKey);Vue.watch(()=>e.senderOptions.map(w=>w.key),w=>{let S=e.searchState.senderKey||"";S&&!w.includes(S)&&t("sender-invalid")},{flush:"sync"});let o=Vue.computed(()=>
|
|
7894
|
+
`,setup(e,{emit:t,expose:s}){let n=Vue.ref(null),r=Vue.ref(null),i=Vue.computed(()=>String(e.searchState.query||"").trim().length>=2||!!e.searchState.senderKey);Vue.watch(()=>e.senderOptions.map(w=>w.key),w=>{let S=e.searchState.senderKey||"";S&&!w.includes(S)&&t("sender-invalid")},{flush:"sync"});let o=Vue.computed(()=>Ly(i.value?e.searchState.results:e.outlineState.results)),a=Vue.computed(()=>{let w=o.value.findIndex(S=>S?.messageId===e.activeMessageId);return w>=0?w:0}),l=Vue.computed(()=>i.value?e.searchState.loading:e.outlineState.loading),c=Vue.computed(()=>{if(i.value)return`${e.searchState.results.length}${e.searchState.hasMore?"+":""}`;let w=e.outlineState.totalCount;return Number.isFinite(w)?String(w):String(e.outlineState.results.length||"")}),d=Vue.computed(()=>{let w=i.value?e.searchState.error:e.outlineState.error;return w?w==="unsupported"?"yeaft.outline.unsupported":"yeaft.outline.error":""}),u=()=>Vue.nextTick(()=>{n.value?.focus?.(),r.value&&(r.value.scrollTop=0)}),f=()=>{let w=r.value;t("load-older",{scrollHeight:w?.scrollHeight||0,scrollTop:w?.scrollTop||0})},p=()=>{if(i.value||e.outlineState.loading||!e.outlineState.hasMore)return;let w=r.value;w&&w.scrollHeight-w.scrollTop-w.clientHeight<=40&&f()},g=w=>{t("move",w?.messageId||null),t("preview",w)},b=w=>{let S=Math.max(0,Math.min(o.value.length-1,w)),y=o.value[S];t("move",y?.messageId||null),y&&t("preview",y)},h=w=>{w.key==="Escape"?(w.preventDefault(),t("close")):w.key==="ArrowDown"&&o.value.length?(w.preventDefault(),b(a.value+1)):w.key==="ArrowUp"&&o.value.length?(w.preventDefault(),b(a.value-1)):w.key==="Enter"&&o.value.length&&(w.preventDefault(),t("select",o.value[a.value]||o.value[0]))};return Vue.watch([o,()=>e.activeMessageId],([w,S])=>{w.some(y=>y?.messageId===S)||t("move",w[0]?.messageId||null)},{immediate:!0}),s({focus:u,restoreOlderScroll:({scrollTop:w=0}={})=>Vue.nextTick(()=>{r.value&&(r.value.scrollTop=w)})}),Vue.onMounted(u),{inputRef:n,listRef:r,isSearching:i,visibleResults:o,activeIndex:a,isLoading:l,countLabel:c,errorKey:d,focus:u,loadOlder:f,onScroll:p,onKeyDown:h,previewResult:g,formatOutlineTime:Dy}}}});function $g(e,t){if(!Array.isArray(e)||e.length===0)return[];let s=new Map;if(Array.isArray(t))for(let i of t)i&&i.vpId&&s.set(i.vpId,i);let n=new Set,r=[];for(let i of e)!i||n.has(i)||(n.add(i),r.push(s.get(i)||{vpId:i}));return r}function dl(e,t,s=null){return!t||!e?null:typeof e.sessionById=="function"?e.sessionById(t,s||null)||null:e.sessions?.[t]||null}function $y(e,t){if(!t)return"idle";if(t.connectionState&&t.connectionState!=="connected")return"offline";let s=t.vpStatuses&&t.vpStatuses[e];return s&&s.state?s.state:"idle"}function Vg(e){let{vpList:t,vpStatuses:s,stoppingVpTurnIds:n,connectionState:r,vpLabelOf:i,vpDescriptionOf:o}=e||{},a={vpStatuses:s||{},stoppingVpTurnIds:n||{},connectionState:r||null},l=(f,p)=>{if(typeof i=="function"){let g=i(f);if(g)return g}return p&&(p.displayName||p.displayNameZh)||f},c=(f,p)=>{if(typeof o=="function"){let g=o(f);if(g)return g}return p&&(p.description||p.role||p.descriptionZh||p.roleZh)||""},d=new Set,u=[];if(Array.isArray(t))for(let f of t)!f||!f.vpId||(d.add(f.vpId),u.push(Lg(f.vpId,l(f.vpId,f),c(f.vpId,f),a)));if(s)for(let f of Object.keys(s))!f||d.has(f)||(d.add(f),u.push(Lg(f,l(f,null),c(f,null),a)));return u}function Lg(e,t,s,n){let r=n&&n.vpStatuses&&n.vpStatuses[e];return{vpId:e,displayName:t||e,description:s||"",status:$y(e,n),turnId:r?.turnId||null,isStopping:!!(r?.turnId&&n?.stoppingVpTurnIds?.[r.turnId]),runningThreadCount:r&&Number.isFinite(r.runningThreadCount)?r.runningThreadCount:0,threads:r&&Array.isArray(r.threads)?r.threads:[]}}var Fg=F(()=>{});function Hi(e){return!e||typeof e!="object"?"":typeof e.ref=="string"&&e.ref?e.ref:typeof e.provider=="string"&&e.provider&&typeof e.id=="string"&&e.id?`${e.provider}/${e.id}`:typeof e.id=="string"?e.id:""}function Jn(e,t){return!e||!t?!1:e.id===t||Hi(e)===t}function Hg(e,t=""){let s=e?.config?.model;return typeof s=="string"&&s.trim()?s.trim():typeof t=="string"&&t.trim()?t.trim():""}function qg(e){if(!Array.isArray(e))return[];let t=[];for(let s of e){if(typeof s!="string")continue;let n=s.trim();!n||t.includes(n)||t.push(n)}return t}function ul(e){return qg(e).filter(t=>(Og[t]??-1)>=Og.medium)}function pl(e){let t=qg(e);return t.length?t.length===1?t[0]:t[t.length-2]:""}function Ng(e,t=""){let s=e?.config?.modelEffort;return typeof s=="string"&&s.trim()?s.trim():typeof t=="string"&&t.trim()?t.trim():""}function Bg(e){let t=[];for(let s of Array.isArray(e)?e:[]){let n=Hi(s);if(!n)continue;let r=s.label||s.id||n,i=ul(s?.effortOptions);t.push({model:s,modelRef:n,label:r,efforts:i,defaultEffort:pl(i)||null})}return t}var Og,Wg=F(()=>{Og=Object.freeze({minimal:0,low:1,medium:2,high:3,xhigh:4,max:5})});function Ug({agentInventoryReady:e=!1,hasYeaftAgent:t=!1,sessionsReady:s=!1,sessionsEmpty:n=!1}={}){return!e||s&&!n?!1:t?s?n:!1:!0}var jg=F(()=>{});function zg({activeSessionFilter:e=null,sessionsStore:t=null,topbarGroup:s=null}={}){return e||t?.activeSessionId||s?.id||null}function Kg(e={}){return e.currentAgentInfo?.online?!0:Array.isArray(e.agents)&&e.agents.some(t=>t&&t.online)}var Yg=F(()=>{});function Gg(e={}){return!e?.warning}var Qg=F(()=>{});function Jg(e,t){return e&&t?`${e}:${t}`:""}function em(e){if(e!==void 0)return e;try{return globalThis.localStorage}catch{return null}}function tm(e){try{let t=JSON.parse(e?.getItem(fl)||"{}");return t&&typeof t=="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function Vy({agentId:e,sessionId:t,validKeys:s=[],storage:n}={}){let r=Jg(e,t);if(!r)return"";let i=em(n),o=tm(i),a=typeof o[r]=="string"?o[r]:"";if(!a||s.includes(a))return a;delete o[r];try{i?.setItem(fl,JSON.stringify(o))}catch{}return""}function Xg({agentId:e,sessionId:t,senderKey:s,storage:n}={}){let r=Jg(e,t);if(!r)return!1;let i=em(n);if(!i)return!1;let o=tm(i);s?o[r]=s:delete o[r];try{return i.setItem(fl,JSON.stringify(o)),!0}catch{return!1}}function Zg(e){let t=e?.updatedAt||e?.endedAt||e?.createdAt,s=t?Date.parse(t):NaN;return Number.isFinite(s)?s:0}function Fy(e){return Object.values(e||{}).filter(Boolean).sort((t,s)=>t.status==="running"&&s.status!=="running"?-1:t.status!=="running"&&s.status==="running"?1:Zg(s)-Zg(t))}var fl,sm,nm=F(()=>{mi();Da();Wa();ug();fg();_i();mg();Ba();Ig();Mg();Rg();Dg();ol();al();La();Fg();Wg();ys();jg();Yg();Qg();Ea();fl="yeaft-history-sender-preferences";sm={name:"YeaftPage",components:{ChatInput:Gs,MessageList:ci,SettingsPanel:ki,YeaftSidebar:dg,SessionInviteModal:pg,SessionCreateModal:en,SessionSettingsModal:gg,WorkbenchPanel:wi,WorkCenterPage:Vi,YeaftDebugPanel:Sg,VpTimelinePane:Tg,YeaftSessionActions:Pg,YeaftConversationOutline:Eg,LlmTab:$i},template:`
|
|
7900
7895
|
<div class="yeaft-page" ref="pageRef">
|
|
7901
7896
|
<!-- Mobile sidebar overlay -->
|
|
7902
7897
|
<div class="yeaft-sidebar-overlay" v-if="store.sessionSidebarOpen && isMobile" @click="store.closeSessionSidebar()"></div>
|
|
@@ -8278,11 +8273,11 @@ ${String(e||"").trim()}
|
|
|
8278
8273
|
@open-vp-library="openVpLibraryFromGroupSettings"
|
|
8279
8274
|
/>
|
|
8280
8275
|
</div>
|
|
8281
|
-
`,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(I=>I),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(""),f=Vue.ref(!1),p=Vue.ref(""),g=null,b=Vue.ref("vp"),h=Vue.ref(null),A=Vue.ref(null),w=Vue.ref(null),S=Vue.ref(null),y=Vue.ref(null),m=Vue.ref(null),v=Vue.ref(!1),E=Vue.ref(null),V=Vue.computed(()=>e.getYeaftHistoryOutlineState()),U=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null,le=G?dl(I,G,e.currentAgent||null):null,Te=Array.isArray(le?.roster)?le.roster:[];return[{key:"user",label:r("yeaft.outline.you")},...Te.map(Me=>({key:`vp:${Me}`,label:s.vpLabel(Me)}))]}),L=Vue.ref(e.yeaftHistorySearchState?.query||""),D=null,M=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},T=()=>{let I=M();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||I?.activeSessionId||null}},C=()=>$y({...T(),validKeys:U.value.map(I=>I.key)}),R=(I="")=>{let{agentId:G,sessionId:le}=T();e.yeaftHistorySearchState={requestId:null,agentId:G,sessionId:le,query:"",senderKey:I,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},B=Vue.computed(()=>{let I=e.currentAgent||"agent",G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||"session";return`yeaft:${I}:${le}`});Vue.watch(B,()=>{w.value=null});let O=null,j=null,ne=I=>{if(!I)return!1;let G=String(I.tagName||"").toLowerCase();return G==="textarea"||G==="input"||I.isContentEditable===!0},ve=({recoverScroll:I=!1}={})=>{let G=S.value;if(!G)return;if(!We.value){G.style.removeProperty("--yeaft-visual-viewport-height");return}let le=window.visualViewport,Te=Math.max(1,Math.round(le?.height||window.innerHeight||1));G.style.setProperty("--yeaft-visual-viewport-height",`${Te}px`),!(!I||le&&window.innerHeight&&le.height<window.innerHeight*.85||ne(document.activeElement))&&window.scrollTo(0,0)},ue=(I={})=>{O!=null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,ve(I)})},be=()=>{ue({recoverScroll:!0}),j&&clearTimeout(j),j=setTimeout(()=>{j=null,ue({recoverScroll:!0})},260)},ie=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")),Ce=Vue.computed(()=>!0),x=I=>{let G=I&&I.id?I.id:null;G&&(e.setActiveSessionFilter(G,{agentId:I.agentId||null}),We.value&&e.closeSessionSidebar())},Y=I=>{},oe=Vue.ref(null),he=Vue.ref(!1),W=320,te=Math.max(W,Math.round(window.innerWidth*.25)),K=localStorage.getItem("yeaft-debug-width"),N=Vue.ref(K?parseInt(K,10):te),H=Vue.computed(()=>({"--yeaft-detail-width":N.value+"px"})),_=I=>{he.value=!0;let G=I.clientX,le=N.value,Te=window.innerWidth*.6,Me=Ht=>{let qt=G-Ht.clientX,Ms=Math.min(Te,Math.max(W,le+qt));N.value=Ms},ze=()=>{he.value=!1,document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze),localStorage.setItem("yeaft-debug-width",String(N.value))};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},J="yeaft-session-status-visible",se=()=>{try{let I=localStorage.getItem(J);return!(I==="0"||I==="false")}catch{return!0}},me=Vue.ref(se()),z=I=>{me.value=!!I;try{localStorage.setItem(J,me.value?"1":"0")}catch{}},ee=()=>z(!me.value),fe=()=>z(!1),ae=220,De=280,$e=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Oe=$e?parseInt($e,10):NaN,je=Vue.ref(Number.isFinite(Oe)&&Oe>=ae?Oe:De),Yt=Vue.computed(()=>({"--yeaft-vp-timeline-width":je.value+"px"})),kt=I=>{let G=I.clientX,le=je.value,Te=Math.max(ae,Math.floor(window.innerWidth*.4)),Me=Ht=>{let qt=G-Ht.clientX,Ms=Math.min(Te,Math.max(ae,le+qt));je.value=Ms},ze=()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze);try{localStorage.setItem("yeaft-vp-timeline-width",String(je.value))}catch{}};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},Dt="(max-width: 768px)",St="(max-width: 1024px)",Lt=typeof window.matchMedia=="function"?window.matchMedia(Dt):null,ft=typeof window.matchMedia=="function"?window.matchMedia(St):null,Ne=(I,G)=>I?I.matches:window.innerWidth<=G,We=Vue.ref(Ne(Lt,768)),$t=Vue.ref(Ne(ft,1024)),Ge=Vue.computed(()=>We.value?!e.sessionSidebarOpen:e.sidebarCollapsed),P=()=>{We.value=Ne(Lt,768),$t.value=Ne(ft,1024)},X=()=>{P(),be()},ge=I=>{I&&(typeof I.addEventListener=="function"?I.addEventListener("change",X):typeof I.addListener=="function"&&I.addListener(X))},de=I=>{I&&(typeof I.removeEventListener=="function"?I.removeEventListener("change",X):typeof I.removeListener=="function"&&I.removeListener(X))},ye=()=>{D&&(clearTimeout(D),D=null),L.value="",R(C()),v.value=!1,E.value=null},Se=()=>{let I=C();L.value="",R(I),v.value=!0,e.loadYeaftHistoryOutline(),I&&e.searchYeaftHistory("",{senderKey:I}),Vue.nextTick(()=>m.value?.focus?.())},Le=()=>{v.value?ye():Se()},He=I=>{v.value&&Cp(I.target)&&ye()},Be=I=>{L.value=I,D&&clearTimeout(D),E.value=null,D=setTimeout(()=>{D=null,e.searchYeaftHistory(L.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},Ke=I=>{D&&clearTimeout(D),D=null,E.value=null,Xg({...T(),senderKey:I}),e.searchYeaftHistory(L.value,{senderKey:I})},Vt=()=>{Xg({...T(),senderKey:""}),E.value=null,e.searchYeaftHistory(L.value,{senderKey:""})},sn=I=>{if(!e.loadYeaftHistoryOutline({append:!0}))return;let G=Vue.watch(()=>V.value.loading,le=>{le||(G(),m.value?.restoreOlderScroll?.(I))})},Ni=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),Bi=I=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(I)},er=I=>Ap({result:I,revealWindow:G=>e.revealYeaftHistoryResult(G),nextTick:()=>Vue.nextTick(),revealMessage:G=>y.value?.revealMessage?.(G),isMobile:We.value,closeOutline:ye}),tr=I=>{if((I.metaKey||I.ctrlKey)&&String(I.key).toLowerCase()==="f"){I.preventDefault(),Se();return}if(I.key==="Escape"){if(v.value){ye();return}if(o.value){Xt();return}}};Vue.onMounted(()=>{P(),window.addEventListener("resize",X),ge(Lt),ge(ft),window.visualViewport?.addEventListener("resize",be),window.visualViewport?.addEventListener("scroll",be),document.addEventListener("click",Ft),document.addEventListener("click",He),document.addEventListener("keydown",tr),ue()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",X),de(Lt),de(ft),window.visualViewport?.removeEventListener("resize",be),window.visualViewport?.removeEventListener("scroll",be),document.removeEventListener("click",Ft),document.removeEventListener("click",He),document.removeEventListener("keydown",tr),O!=null&&cancelAnimationFrame(O),j&&clearTimeout(j),D&&clearTimeout(D)}),Vue.watch(()=>e.yeaftConversationId,I=>{I&&e.activeConversations[0]!==I&&(e.activeConversations=[I])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{ye(),R(C())});let Wi=()=>{e.leaveYeaft()},Ui=(I,G,le)=>{let Te=M();if(Te&&Te.activeNeedsInvite){let qt=Te.activeSession;qt&&Jt.delete(qt.id);return}let Me=e.yeaftActiveSessionFilter||Te&&Te.activeSessionId||"grp_default",ze=fi(I).mentions,Ht=Array.isArray(G)?G:void 0;e.sendYeaftSessionMessage({groupId:Me,text:I,mentions:ze,attachments:Ht,quote:le})},ji=I=>{I&&(w.value=I,A.value?.focusInput?.())},zi=I=>{w.value=null,A.value?.replaceDraft?.(I||"")},Ki=()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;G&&e.cancelYeaftSession(G)},nn=(I="")=>{let G=et.value;G&&e.enterWorkCenterFromSession(G,I)},sr=()=>{if(We.value){e.toggleSessionSidebar();return}e.toggleSidebar()},rn=()=>{i.value=!i.value},Je=()=>{i.value=!1},nr=()=>{e.reloadYeaftMessages()},Yi=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},Gi=()=>{window.location.reload()},Qi=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;return G?e.isYeaftSessionProcessing(G,e.currentAgent||null):!1}),et=Vue.computed(()=>{let I=M();if(!I||!I.sessions)return null;let G=e.yeaftActiveSessionFilter||null;if(G&&typeof I.sessionById=="function"){let le=I.sessionById(G,e.currentAgent||null);if(le)return le}if(I.activeSessionId&&typeof I.sessionById=="function"){let le=I.sessionById(I.activeSessionId,e.currentAgent||null);if(le)return le}return typeof I.sessionById=="function"?I.sessionById("grp_default",e.currentAgent||null):null}),rr=()=>zg({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:M(),topbarGroup:et.value}),on=Vue.computed(()=>{let I=et.value||{},G=typeof I.id=="string"?I.id.trim():"",le=[I.title,I.name,I.config?.title,I.config?.name];for(let Te of le){let Me=typeof Te=="string"?Te.trim():"";if(Me&&!(G&&Me===G)&&!/^(sessions?|groups?)\//i.test(Me)&&!/^session_[A-Za-z0-9_-]+$/.test(Me)&&!(I.workDir&&Me===I.workDir))return Me}return""}),Xi=Vue.computed(()=>et.value&&typeof et.value.announcement=="string"?et.value.announcement:""),Gt=Vue.computed(()=>Hg(et.value,e.yeaftModel||"")),ir=Vue.computed(()=>{let I=Gt.value;return I&&e.yeaftAvailableModels.find(G=>Jn(G,I))||null}),an=I=>ul(I?.effortOptions),Zi=Vue.computed(()=>Ng(et.value,e.yeaftModelEffort||"")),Qt=Vue.computed(()=>{let I=Array.isArray(ir.value?.effortOptions)?ir.value.effortOptions.filter(Boolean):[];return I.length?I.includes(Zi.value)?Zi.value:pl(I):null}),Ss=Vue.computed(()=>Bg(e.yeaftAvailableModels)),Ji=(I,G)=>Jn(I,Gt.value)?G?G===Qt.value:!an(I).length:!1,eo=I=>!I||!Jn(I.model,Gt.value)?!1:I.efforts.length?I.efforts.includes(Qt.value):!0,to=()=>{o.value=!0},Xt=()=>{o.value=!1},or=I=>{I.stopPropagation(),e.yeaftAvailableModels.length&&(o.value?Xt():to())},It=(I,G=null)=>{if(!I)return;let le=et.value?.id||null;e.switchYeaftModel(I,le,G),Xt()},Zt=I=>!I||!Number.isFinite(I)||I<=0?"":I>=1e6?`${Math.round(I/1e5)/10}m`:I>=1e3?`${Math.round(I/1e3)}k`:String(I),ot=I=>{let G=Zt(I?.contextWindow),le=Zt(I?.maxOutput);return G&&le?`${G} \xB7 ${le} out`:G},Ft=I=>{if(!o.value)return;I.target.closest(".yeaft-topbar-model, .yeaft-topbar-model-dropdown")||Xt()},so=()=>{a.value||(b.value="vp",h.value=null),a.value=!a.value},ln=({initialTab:I="vp",editVpId:G=null}={})=>{b.value=["vp","search","mcp"].includes(I)?I:"vp",h.value=b.value==="vp"&&G||null,a.value=!0},Is=()=>{o.value=!1,l.value=!0},Cs=I=>{Ze(I)&&(l.value=!1)},ar=async()=>{if(!(u.value||f.value)){f.value=!0,p.value="";try{let I={"Content-Type":"application/json"};t.token&&(I.Authorization=`Bearer ${t.token}`);let G=await fetch("/api/user/agent-secret",{headers:I});if(!G.ok){let Me=r("yeaft.onboarding.secretError");try{let ze=await G.json();ze?.error&&(Me=ze.error)}catch{}throw new Error(Me)}let le=await G.json(),Te=le?.agentSecret||le?.agent_secret||"";if(u.value=String(Te||"").trim(),!u.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(I){p.value=I?.message||r("yeaft.onboarding.secretError")}finally{f.value=!1}}},As=()=>{c.value=!0},lr=I=>{c.value=!1},cr=async(I,G)=>{if(G&&!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{let le=typeof G=="string"?G:G?.value||"";if(!le)return;await navigator.clipboard.writeText(le),d.value=I||"",g&&clearTimeout(g),g=setTimeout(()=>{d.value="",g=null},1800)}catch{}},cn=(I,G)=>{},xs=(I={})=>{Gg(I)&&(l.value=!1)},Jt=Vue.reactive(new Set),Ot=Vue.computed(()=>{let I=M();return I?I.activeSession:null}),dr=I=>{if(!I)return"";if(I.id==="grp_default"&&(I.name==="Default"||!I.name))try{let G=typeof window<"u"?window.i18n:null;if(G&&G.global&&typeof G.global.t=="function")return G.global.t("yeaft.session.defaultName")}catch{}return I.name||I.id||""},no=Vue.computed(()=>dr(Ot.value)),dn=Vue.computed(()=>{let I=M();if(!I||!I.activeNeedsInvite)return!1;let G=I.activeSession;return G?!Jt.has(G.id):!1}),ur=Vue.computed(()=>{let I=M();return!!(I&&I.activeNeedsInvite)}),gl=Vue.computed(()=>{let I=M();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot)}),k=Vue.computed(()=>{let I=M();return Ug({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Kg(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot),sessionsEmpty:!!(I&&I.isEmpty)})});Vue.watch(k,I=>{I&&ar()},{immediate:!0});let $="npm install -g @yeaft/webchat-agent",q=Vue.computed(()=>{let G=(typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost:3456").replace(/^http:/,"ws:").replace(/^https:/,"wss:"),le=u.value||r("yeaft.onboarding.secretPending");return`yeaft-agent install --server ${G} --name yeaft-agent --secret ${le}`}),pe="gh auth login && yeaft-agent llm use github-copilot --model gpt-5.5",ke=()=>{let I=Ot.value;I&&Jt.add(I.id),hl(I?I.id:null)},re=()=>{let I=Ot.value;I&&Jt.add(I.id)},Ve=Vue.ref(!1),Ue=Vue.ref(null),we=Vue.ref(null),ce=Vue.ref("session"),Qe=Vue.ref(""),Ts=(I={})=>{let G=I&&(I.sessionId||I.groupId)||null,le=I&&I.editVpId||"",Te=le?"members":I&&I.section||"session";G&&(Ue.value=G,we.value=I&&I.agentId||null,ce.value=Te,Qe.value=le,Ve.value=!0)},un=()=>{let I=rr();I&&Ts({sessionId:I,section:"session"})},ml=()=>{Ve.value=!1,Ue.value=null,we.value=null,Qe.value=""},rm=()=>{ml(),ln({initialTab:"vp"})},hl=I=>{I&&Ts({sessionId:I,section:"members"})};Vue.watch(()=>{let I=Ot.value;return I?I.id+":"+(Array.isArray(I.roster)?I.roster.length:0)+":"+(I.defaultVpId||""):""},(I,G)=>{let le=Ot.value;le&&I!==G&&Array.isArray(le.roster)&&le.roster.length>0&&Jt.delete(le.id)}),typeof Vue.onBeforeUnmount=="function"&&Vue.onBeforeUnmount(()=>{g&&clearTimeout(g),g=null});let im=()=>{a.value=!1},om=Vue.computed(()=>!a.value&&!k.value&&me.value),am=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;if(!G)return[];let Te=(typeof I?.sessionById=="function"?I.sessionById(G,e.currentAgent||null):null)?.agentId||e.currentAgent||null,Me=Te?`${Te}${G}`:G,ze=e.yeaftActiveTasksBySession?.[Me]||{};return Vy(ze)}),lm=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;if(!le)return[];let Te=dl(G,le,e.currentAgent||null),Me=Te&&Array.isArray(Te.roster)?Te.roster:[];if(Me.length===0)return[];let ze=new Set(Me),Ht=$g(Me,s.vpList||[]),qt=e.vpStatuses||{},Ms={},pr=e.currentAgent||null;for(let qe of Object.values(qt)){if(!qe||!qe.vpId)continue;let fr=qe.sessionId??qe.groupId;fr&&fr!==le||pr&&qe.agentId&&qe.agentId!==pr||ze.has(qe.vpId)&&(Ms[qe.vpId]=qe)}let vl={};for(let qe of Object.values(e.activeVpTurns||{}))!qe?.turnId||!qe?.sessionId||qe.sessionId!==le||pr&&qe.agentId&&qe.agentId!==pr||Object.entries(e.stoppingVpTurnIds||{}).some(([fr])=>e.activeVpTurns?.[fr]===qe)&&(vl[qe.turnId]=!0);return Vg({vpList:Ht,vpStatuses:Ms,stoppingVpTurnIds:vl,connectionState:e.connectionState,vpLabelOf:qe=>s.vpLabel(qe),vpDescriptionOf:qe=>s.vpDescription(qe)})});return{store:e,pageRef:S,effectiveSidebarCollapsed:Ge,debugMode:i,modelDropdownOpen:o,topbarGroup:et,topbarSessionTitle:on,topbarModel:Gt,topbarEffort:Qt,topbarModelRows:Ss,selectableEffortsForModel:an,isModelSelectionActive:Ji,isModelRowActive:eo,modelOptionRef:Hi,modelOptionMatchesRef:Jn,showSettings:a,showLlmConfig:l,sessionCreateOpen:c,settingsInitialTab:b,settingsInitialEditVpId:h,chatInputRef:A,messageQuote:w,messageListRef:y,historySearchRef:m,historySearchOpen:v,historySearchActiveMessageId:E,historyOutlineState:V,historySenderOptions:U,toggleHistorySearch:Le,closeHistorySearch:ye,onHistorySearchQuery:Be,onHistorySenderChange:Ke,onHistorySenderInvalid:Vt,loadOlderHistoryOutline:sn,loadMoreHistorySearchResults:Ni,previewHistorySearchResult:Bi,selectHistorySearchResult:er,yeaftInputDraftKey:B,openSettings:ln,isMobile:We,isNarrowDetail:$t,detailPanel:oe,isResizingDetail:he,detailWidthStyle:H,startDetailResize:_,isProcessing:Qi,goBack:Wi,sendMessage:Ui,setMessageQuote:ji,editMessageAsNew:zi,cancelYeaft:Ki,openWorkItemDraft:nn,toggleSidebar:sr,toggleDebug:rn,closeDebug:Je,reloadMessages:nr,retryConversationInventory:Yi,reloadPage:Gi,toggleModelDropdown:or,selectModel:It,openLlmConfig:Is,trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,closeLlmConfigFromOverlay:Cs,openSessionCreate:As,onSessionCreated:lr,copyOnboardingCommand:cr,copiedOnboardingCommand:d,onLlmConfigMessage:cn,onLlmConfigSaved:xs,formatTokens:Zt,formatModelCtx:ot,toggleSettings:so,onSettingsSaved:im,sidebarV2Enabled:Ce,onSelectGroupV2:x,onSelectChat:Y,canUseWorkbench:ie,shouldShowInviteModal:dn,inviteGroupName:no,onInviteOpenLibrary:ke,onInviteDismiss:re,isActiveGroupEmpty:ur,conversationInventoryReady:gl,showOnboardingGuide:k,installAgentCommand:$,connectAgentCommand:q,copilotCommand:pe,agentSecret:u,agentSecretLoading:f,agentSecretError:p,groupSettingsOpen:Ve,groupSettingsId:Ue,groupSettingsAgentId:we,groupSettingsSection:ce,groupSettingsEditVpId:Qe,openSessionSettings:Ts,openAnnouncementSettings:un,closeGroupSettings:ml,openVpLibraryFromGroupSettings:rm,openMemberEditor:hl,showVpTimeline:om,vpTimelineRows:lm,sessionStatusTasksForActiveSession:am,sessionStatusAnnouncementText:Xi,sessionStatusVisible:me,toggleSessionStatus:ee,closeSessionStatus:fe,timelineWidthStyle:Yt,startTimelineResize:kt,onEditVpFromTimeline:I=>{if(!I)return;let G=rr();G&&Ts({sessionId:G,section:"members",editVpId:I})},onMentionVpFromTimeline:I=>{if(!I)return;let G=A.value;G&&typeof G.appendMention=="function"&&G.appendMention(I)},onCancelVpFromTimeline:I=>{if(!I)return;let G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;le&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(I,le)},onCancelTaskFromTimeline:I=>!I?.id||!I.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:I.agentId,sessionId:I.sessionId,taskId:I.id})}}}});var Hy=cm(()=>{Br();ct();Ws();bu();xt();Cu();xu();Mu();Ru();ag();nm();za();Ta();window.Pinia={...Pinia,useChatStore:null,useAuthStore:null};var Fy={components:{LoginPage:Pu,ChatPage:og,YeaftPage:sm},template:`
|
|
8276
|
+
`,setup(){let e=Pinia.useChatStore(),t=Pinia.useAuthStore(),s=Pinia.useVpStore(),n=Vue.getCurrentInstance(),r=n&&n.appContext.config.globalProperties.$t||(I=>I),i=Vue.ref(!1),o=Vue.ref(!1),a=Vue.ref(!1),l=Vue.ref(!1),c=Vue.ref(!1),d=Vue.ref(""),u=Vue.ref(""),f=Vue.ref(!1),p=Vue.ref(""),g=null,b=Vue.ref("vp"),h=Vue.ref(null),A=Vue.ref(null),w=Vue.ref(null),S=Vue.ref(null),y=Vue.ref(null),m=Vue.ref(null),v=Vue.ref(!1),E=Vue.ref(null),V=Vue.computed(()=>e.getYeaftHistoryOutlineState()),U=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null,le=G?dl(I,G,e.currentAgent||null):null,Te=Array.isArray(le?.roster)?le.roster:[];return[{key:"user",label:r("yeaft.outline.you")},...Te.map(Me=>({key:`vp:${Me}`,label:s.vpLabel(Me)}))]}),L=Vue.ref(e.yeaftHistorySearchState?.query||""),D=null,M=()=>{try{return window.Pinia?.useSessionsStore?.()||null}catch{return null}},T=()=>{let I=M();return{agentId:e.currentAgent||null,sessionId:e.yeaftActiveSessionFilter||I?.activeSessionId||null}},C=()=>Vy({...T(),validKeys:U.value.map(I=>I.key)}),R=(I="")=>{let{agentId:G,sessionId:le}=T();e.yeaftHistorySearchState={requestId:null,agentId:G,sessionId:le,query:"",senderKey:I,loading:!1,results:[],hasMore:!1,nextBeforeSeq:null,error:null}},B=Vue.computed(()=>{let I=e.currentAgent||"agent",G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||"session";return`yeaft:${I}:${le}`});Vue.watch(B,()=>{w.value=null});let O=null,j=null,ne=I=>{if(!I)return!1;let G=String(I.tagName||"").toLowerCase();return G==="textarea"||G==="input"||I.isContentEditable===!0},ve=({recoverScroll:I=!1}={})=>{let G=S.value;if(!G)return;if(!We.value){G.style.removeProperty("--yeaft-visual-viewport-height");return}let le=window.visualViewport,Te=Math.max(1,Math.round(le?.height||window.innerHeight||1));G.style.setProperty("--yeaft-visual-viewport-height",`${Te}px`),!(!I||le&&window.innerHeight&&le.height<window.innerHeight*.85||ne(document.activeElement))&&window.scrollTo(0,0)},ue=(I={})=>{O!=null&&cancelAnimationFrame(O),O=requestAnimationFrame(()=>{O=null,ve(I)})},be=()=>{ue({recoverScroll:!0}),j&&clearTimeout(j),j=setTimeout(()=>{j=null,ue({recoverScroll:!0})},260)},ie=Vue.computed(()=>e.hasCapability("terminal")||e.hasCapability("file_editor")),Ce=Vue.computed(()=>!0),x=I=>{let G=I&&I.id?I.id:null;G&&(e.setActiveSessionFilter(G,{agentId:I.agentId||null}),We.value&&e.closeSessionSidebar())},Y=I=>{},oe=Vue.ref(null),he=Vue.ref(!1),W=320,te=Math.max(W,Math.round(window.innerWidth*.25)),K=localStorage.getItem("yeaft-debug-width"),N=Vue.ref(K?parseInt(K,10):te),H=Vue.computed(()=>({"--yeaft-detail-width":N.value+"px"})),_=I=>{he.value=!0;let G=I.clientX,le=N.value,Te=window.innerWidth*.6,Me=Ht=>{let qt=G-Ht.clientX,Ms=Math.min(Te,Math.max(W,le+qt));N.value=Ms},ze=()=>{he.value=!1,document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze),localStorage.setItem("yeaft-debug-width",String(N.value))};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},J="yeaft-session-status-visible",se=()=>{try{let I=localStorage.getItem(J);return!(I==="0"||I==="false")}catch{return!0}},me=Vue.ref(se()),z=I=>{me.value=!!I;try{localStorage.setItem(J,me.value?"1":"0")}catch{}},ee=()=>z(!me.value),fe=()=>z(!1),ae=220,De=280,$e=(()=>{try{return localStorage.getItem("yeaft-vp-timeline-width")}catch{return null}})(),Oe=$e?parseInt($e,10):NaN,je=Vue.ref(Number.isFinite(Oe)&&Oe>=ae?Oe:De),Gt=Vue.computed(()=>({"--yeaft-vp-timeline-width":je.value+"px"})),kt=I=>{let G=I.clientX,le=je.value,Te=Math.max(ae,Math.floor(window.innerWidth*.4)),Me=Ht=>{let qt=G-Ht.clientX,Ms=Math.min(Te,Math.max(ae,le+qt));je.value=Ms},ze=()=>{document.removeEventListener("mousemove",Me),document.removeEventListener("mouseup",ze);try{localStorage.setItem("yeaft-vp-timeline-width",String(je.value))}catch{}};document.addEventListener("mousemove",Me),document.addEventListener("mouseup",ze)},Dt="(max-width: 768px)",St="(max-width: 1024px)",Lt=typeof window.matchMedia=="function"?window.matchMedia(Dt):null,ft=typeof window.matchMedia=="function"?window.matchMedia(St):null,Ne=(I,G)=>I?I.matches:window.innerWidth<=G,We=Vue.ref(Ne(Lt,768)),$t=Vue.ref(Ne(ft,1024)),Ge=Vue.computed(()=>We.value?!e.sessionSidebarOpen:e.sidebarCollapsed),P=()=>{We.value=Ne(Lt,768),$t.value=Ne(ft,1024)},X=()=>{P(),be()},ge=I=>{I&&(typeof I.addEventListener=="function"?I.addEventListener("change",X):typeof I.addListener=="function"&&I.addListener(X))},de=I=>{I&&(typeof I.removeEventListener=="function"?I.removeEventListener("change",X):typeof I.removeListener=="function"&&I.removeListener(X))},ye=()=>{D&&(clearTimeout(D),D=null),L.value="",R(C()),v.value=!1,E.value=null},Se=()=>{let I=C();L.value="",R(I),v.value=!0,e.loadYeaftHistoryOutline(),I&&e.searchYeaftHistory("",{senderKey:I}),Vue.nextTick(()=>m.value?.focus?.())},Le=()=>{v.value?ye():Se()},He=I=>{v.value&&Cp(I.target)&&ye()},Be=I=>{L.value=I,D&&clearTimeout(D),E.value=null,D=setTimeout(()=>{D=null,e.searchYeaftHistory(L.value,{senderKey:e.yeaftHistorySearchState.senderKey})},220)},Ke=I=>{D&&clearTimeout(D),D=null,E.value=null,Xg({...T(),senderKey:I}),e.searchYeaftHistory(L.value,{senderKey:I})},Vt=()=>{Xg({...T(),senderKey:""}),E.value=null,e.searchYeaftHistory(L.value,{senderKey:""})},sn=I=>{if(!e.loadYeaftHistoryOutline({append:!0}))return;let G=Vue.watch(()=>V.value.loading,le=>{le||(G(),m.value?.restoreOlderScroll?.(I))})},Ni=()=>e.searchYeaftHistory(e.yeaftHistorySearchState.query,{append:!0,senderKey:e.yeaftHistorySearchState.senderKey}),Bi=I=>{e.hasCapability("session_history_window_prefetch")&&e.loadYeaftHistoryWindow(I)},er=I=>Ap({result:I,revealWindow:G=>e.revealYeaftHistoryResult(G),nextTick:()=>Vue.nextTick(),revealMessage:G=>y.value?.revealMessage?.(G),isMobile:We.value,closeOutline:ye}),tr=I=>{if((I.metaKey||I.ctrlKey)&&String(I.key).toLowerCase()==="f"){I.preventDefault(),Se();return}if(I.key==="Escape"){if(v.value){ye();return}if(o.value){Zt();return}}};Vue.onMounted(()=>{P(),window.addEventListener("resize",X),ge(Lt),ge(ft),window.visualViewport?.addEventListener("resize",be),window.visualViewport?.addEventListener("scroll",be),document.addEventListener("click",Ft),document.addEventListener("click",He),document.addEventListener("keydown",tr),ue()}),Vue.onUnmounted(()=>{window.removeEventListener("resize",X),de(Lt),de(ft),window.visualViewport?.removeEventListener("resize",be),window.visualViewport?.removeEventListener("scroll",be),document.removeEventListener("click",Ft),document.removeEventListener("click",He),document.removeEventListener("keydown",tr),O!=null&&cancelAnimationFrame(O),j&&clearTimeout(j),D&&clearTimeout(D)}),Vue.watch(()=>e.yeaftConversationId,I=>{I&&e.activeConversations[0]!==I&&(e.activeConversations=[I])}),Vue.watch(()=>[e.currentAgent,e.yeaftActiveSessionFilter],()=>{ye(),R(C())});let Wi=()=>{e.leaveYeaft()},Ui=(I,G,le)=>{let Te=M();if(Te&&Te.activeNeedsInvite){let qt=Te.activeSession;qt&&es.delete(qt.id);return}let Me=e.yeaftActiveSessionFilter||Te&&Te.activeSessionId||"grp_default",ze=fi(I).mentions,Ht=Array.isArray(G)?G:void 0;e.sendYeaftSessionMessage({groupId:Me,text:I,mentions:ze,attachments:Ht,quote:le})},ji=I=>{I&&(w.value=I,A.value?.focusInput?.())},zi=I=>{w.value=null,A.value?.replaceDraft?.(I||"")},Ki=()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;G&&e.cancelYeaftSession(G)},nn=(I="")=>{let G=et.value;G&&e.enterWorkCenterFromSession(G,I)},sr=()=>{if(We.value){e.toggleSessionSidebar();return}e.toggleSidebar()},rn=()=>{i.value=!i.value},Je=()=>{i.value=!1},nr=()=>{e.reloadYeaftMessages()},Yi=()=>{if(typeof e.requestYeaftSessionInventory=="function"){e.requestYeaftSessionInventory();return}e._hasHandledAgentList=!1,e._hasHandledYeaftSessionHydrate=!1,e.yeaftSessionHydrateError=null,e.sendWsMessage({type:"get_agents"})},Gi=()=>{window.location.reload()},Qi=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;return G?e.isYeaftSessionProcessing(G,e.currentAgent||null):!1}),et=Vue.computed(()=>{let I=M();if(!I||!I.sessions)return null;let G=e.yeaftActiveSessionFilter||null;if(G&&typeof I.sessionById=="function"){let le=I.sessionById(G,e.currentAgent||null);if(le)return le}if(I.activeSessionId&&typeof I.sessionById=="function"){let le=I.sessionById(I.activeSessionId,e.currentAgent||null);if(le)return le}return typeof I.sessionById=="function"?I.sessionById("grp_default",e.currentAgent||null):null}),rr=()=>zg({activeSessionFilter:e.yeaftActiveSessionFilter,sessionsStore:M(),topbarGroup:et.value}),on=Vue.computed(()=>{let I=et.value||{},G=typeof I.id=="string"?I.id.trim():"",le=[I.title,I.name,I.config?.title,I.config?.name];for(let Te of le){let Me=typeof Te=="string"?Te.trim():"";if(Me&&!(G&&Me===G)&&!/^(sessions?|groups?)\//i.test(Me)&&!/^session_[A-Za-z0-9_-]+$/.test(Me)&&!(I.workDir&&Me===I.workDir))return Me}return""}),Xi=Vue.computed(()=>et.value&&typeof et.value.announcement=="string"?et.value.announcement:""),Qt=Vue.computed(()=>Hg(et.value,e.yeaftModel||"")),ir=Vue.computed(()=>{let I=Qt.value;return I&&e.yeaftAvailableModels.find(G=>Jn(G,I))||null}),an=I=>ul(I?.effortOptions),Zi=Vue.computed(()=>Ng(et.value,e.yeaftModelEffort||"")),Xt=Vue.computed(()=>{let I=Array.isArray(ir.value?.effortOptions)?ir.value.effortOptions.filter(Boolean):[];return I.length?I.includes(Zi.value)?Zi.value:pl(I):null}),Ss=Vue.computed(()=>Bg(e.yeaftAvailableModels)),Ji=(I,G)=>Jn(I,Qt.value)?G?G===Xt.value:!an(I).length:!1,eo=I=>!I||!Jn(I.model,Qt.value)?!1:I.efforts.length?I.efforts.includes(Xt.value):!0,to=()=>{o.value=!0},Zt=()=>{o.value=!1},or=I=>{I.stopPropagation(),e.yeaftAvailableModels.length&&(o.value?Zt():to())},It=(I,G=null)=>{if(!I)return;let le=et.value?.id||null;e.switchYeaftModel(I,le,G),Zt()},Jt=I=>!I||!Number.isFinite(I)||I<=0?"":I>=1e6?`${Math.round(I/1e5)/10}m`:I>=1e3?`${Math.round(I/1e3)}k`:String(I),ot=I=>{let G=Jt(I?.contextWindow),le=Jt(I?.maxOutput);return G&&le?`${G} \xB7 ${le} out`:G},Ft=I=>{if(!o.value)return;I.target.closest(".yeaft-topbar-model, .yeaft-topbar-model-dropdown")||Zt()},so=()=>{a.value||(b.value="vp",h.value=null),a.value=!a.value},ln=({initialTab:I="vp",editVpId:G=null}={})=>{b.value=["vp","search","mcp"].includes(I)?I:"vp",h.value=b.value==="vp"&&G||null,a.value=!0},Is=()=>{o.value=!1,l.value=!0},Cs=I=>{Ze(I)&&(l.value=!1)},ar=async()=>{if(!(u.value||f.value)){f.value=!0,p.value="";try{let I={"Content-Type":"application/json"};t.token&&(I.Authorization=`Bearer ${t.token}`);let G=await fetch("/api/user/agent-secret",{headers:I});if(!G.ok){let Me=r("yeaft.onboarding.secretError");try{let ze=await G.json();ze?.error&&(Me=ze.error)}catch{}throw new Error(Me)}let le=await G.json(),Te=le?.agentSecret||le?.agent_secret||"";if(u.value=String(Te||"").trim(),!u.value)throw new Error(r("yeaft.onboarding.secretError"))}catch(I){p.value=I?.message||r("yeaft.onboarding.secretError")}finally{f.value=!1}}},As=()=>{c.value=!0},lr=I=>{c.value=!1},cr=async(I,G)=>{if(G&&!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{let le=typeof G=="string"?G:G?.value||"";if(!le)return;await navigator.clipboard.writeText(le),d.value=I||"",g&&clearTimeout(g),g=setTimeout(()=>{d.value="",g=null},1800)}catch{}},cn=(I,G)=>{},xs=(I={})=>{Gg(I)&&(l.value=!1)},es=Vue.reactive(new Set),Ot=Vue.computed(()=>{let I=M();return I?I.activeSession:null}),dr=I=>{if(!I)return"";if(I.id==="grp_default"&&(I.name==="Default"||!I.name))try{let G=typeof window<"u"?window.i18n:null;if(G&&G.global&&typeof G.global.t=="function")return G.global.t("yeaft.session.defaultName")}catch{}return I.name||I.id||""},no=Vue.computed(()=>dr(Ot.value)),dn=Vue.computed(()=>{let I=M();if(!I||!I.activeNeedsInvite)return!1;let G=I.activeSession;return G?!es.has(G.id):!1}),ur=Vue.computed(()=>{let I=M();return!!(I&&I.activeNeedsInvite)}),gl=Vue.computed(()=>{let I=M();return e._hasHandledAgentList===!0&&e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot)}),k=Vue.computed(()=>{let I=M();return Ug({agentInventoryReady:e._hasHandledAgentList===!0,hasYeaftAgent:Kg(e),sessionsReady:e._hasHandledYeaftSessionHydrate===!0&&!!(I&&I.hasLoadedSnapshot),sessionsEmpty:!!(I&&I.isEmpty)})});Vue.watch(k,I=>{I&&ar()},{immediate:!0});let $="npm install -g @yeaft/webchat-agent",q=Vue.computed(()=>{let G=(typeof window<"u"&&window.location?.origin?window.location.origin:"http://localhost:3456").replace(/^http:/,"ws:").replace(/^https:/,"wss:"),le=u.value||r("yeaft.onboarding.secretPending");return`yeaft-agent install --server ${G} --name yeaft-agent --secret ${le}`}),pe="gh auth login && yeaft-agent llm use github-copilot --model gpt-5.5",ke=()=>{let I=Ot.value;I&&es.add(I.id),hl(I?I.id:null)},re=()=>{let I=Ot.value;I&&es.add(I.id)},Ve=Vue.ref(!1),Ue=Vue.ref(null),we=Vue.ref(null),ce=Vue.ref("session"),Qe=Vue.ref(""),Ts=(I={})=>{let G=I&&(I.sessionId||I.groupId)||null,le=I&&I.editVpId||"",Te=le?"members":I&&I.section||"session";G&&(Ue.value=G,we.value=I&&I.agentId||null,ce.value=Te,Qe.value=le,Ve.value=!0)},un=()=>{let I=rr();I&&Ts({sessionId:I,section:"session"})},ml=()=>{Ve.value=!1,Ue.value=null,we.value=null,Qe.value=""},rm=()=>{ml(),ln({initialTab:"vp"})},hl=I=>{I&&Ts({sessionId:I,section:"members"})};Vue.watch(()=>{let I=Ot.value;return I?I.id+":"+(Array.isArray(I.roster)?I.roster.length:0)+":"+(I.defaultVpId||""):""},(I,G)=>{let le=Ot.value;le&&I!==G&&Array.isArray(le.roster)&&le.roster.length>0&&es.delete(le.id)}),typeof Vue.onBeforeUnmount=="function"&&Vue.onBeforeUnmount(()=>{g&&clearTimeout(g),g=null});let im=()=>{a.value=!1},om=Vue.computed(()=>!a.value&&!k.value&&me.value),am=Vue.computed(()=>{let I=M(),G=e.yeaftActiveSessionFilter||I?.activeSessionId||null;if(!G)return[];let Te=(typeof I?.sessionById=="function"?I.sessionById(G,e.currentAgent||null):null)?.agentId||e.currentAgent||null,Me=Te?`${Te}${G}`:G,ze=e.yeaftActiveTasksBySession?.[Me]||{};return Fy(ze)}),lm=Vue.computed(()=>{if(!e.yeaftConversationId)return[];let G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;if(!le)return[];let Te=dl(G,le,e.currentAgent||null),Me=Te&&Array.isArray(Te.roster)?Te.roster:[];if(Me.length===0)return[];let ze=new Set(Me),Ht=$g(Me,s.vpList||[]),qt=e.vpStatuses||{},Ms={},pr=e.currentAgent||null;for(let qe of Object.values(qt)){if(!qe||!qe.vpId)continue;let fr=qe.sessionId??qe.groupId;fr&&fr!==le||pr&&qe.agentId&&qe.agentId!==pr||ze.has(qe.vpId)&&(Ms[qe.vpId]=qe)}let vl={};for(let qe of Object.values(e.activeVpTurns||{}))!qe?.turnId||!qe?.sessionId||qe.sessionId!==le||pr&&qe.agentId&&qe.agentId!==pr||Object.entries(e.stoppingVpTurnIds||{}).some(([fr])=>e.activeVpTurns?.[fr]===qe)&&(vl[qe.turnId]=!0);return Vg({vpList:Ht,vpStatuses:Ms,stoppingVpTurnIds:vl,connectionState:e.connectionState,vpLabelOf:qe=>s.vpLabel(qe),vpDescriptionOf:qe=>s.vpDescription(qe)})});return{store:e,pageRef:S,effectiveSidebarCollapsed:Ge,debugMode:i,modelDropdownOpen:o,topbarGroup:et,topbarSessionTitle:on,topbarModel:Qt,topbarEffort:Xt,topbarModelRows:Ss,selectableEffortsForModel:an,isModelSelectionActive:Ji,isModelRowActive:eo,modelOptionRef:Hi,modelOptionMatchesRef:Jn,showSettings:a,showLlmConfig:l,sessionCreateOpen:c,settingsInitialTab:b,settingsInitialEditVpId:h,chatInputRef:A,messageQuote:w,messageListRef:y,historySearchRef:m,historySearchOpen:v,historySearchActiveMessageId:E,historyOutlineState:V,historySenderOptions:U,toggleHistorySearch:Le,closeHistorySearch:ye,onHistorySearchQuery:Be,onHistorySenderChange:Ke,onHistorySenderInvalid:Vt,loadOlderHistoryOutline:sn,loadMoreHistorySearchResults:Ni,previewHistorySearchResult:Bi,selectHistorySearchResult:er,yeaftInputDraftKey:B,openSettings:ln,isMobile:We,isNarrowDetail:$t,detailPanel:oe,isResizingDetail:he,detailWidthStyle:H,startDetailResize:_,isProcessing:Qi,goBack:Wi,sendMessage:Ui,setMessageQuote:ji,editMessageAsNew:zi,cancelYeaft:Ki,openWorkItemDraft:nn,toggleSidebar:sr,toggleDebug:rn,closeDebug:Je,reloadMessages:nr,retryConversationInventory:Yi,reloadPage:Gi,toggleModelDropdown:or,selectModel:It,openLlmConfig:Is,trackOverlayPointerDown:nt,trackOverlayPointerUp:rt,clearOverlayPointerGesture:it,closeLlmConfigFromOverlay:Cs,openSessionCreate:As,onSessionCreated:lr,copyOnboardingCommand:cr,copiedOnboardingCommand:d,onLlmConfigMessage:cn,onLlmConfigSaved:xs,formatTokens:Jt,formatModelCtx:ot,toggleSettings:so,onSettingsSaved:im,sidebarV2Enabled:Ce,onSelectGroupV2:x,onSelectChat:Y,canUseWorkbench:ie,shouldShowInviteModal:dn,inviteGroupName:no,onInviteOpenLibrary:ke,onInviteDismiss:re,isActiveGroupEmpty:ur,conversationInventoryReady:gl,showOnboardingGuide:k,installAgentCommand:$,connectAgentCommand:q,copilotCommand:pe,agentSecret:u,agentSecretLoading:f,agentSecretError:p,groupSettingsOpen:Ve,groupSettingsId:Ue,groupSettingsAgentId:we,groupSettingsSection:ce,groupSettingsEditVpId:Qe,openSessionSettings:Ts,openAnnouncementSettings:un,closeGroupSettings:ml,openVpLibraryFromGroupSettings:rm,openMemberEditor:hl,showVpTimeline:om,vpTimelineRows:lm,sessionStatusTasksForActiveSession:am,sessionStatusAnnouncementText:Xi,sessionStatusVisible:me,toggleSessionStatus:ee,closeSessionStatus:fe,timelineWidthStyle:Gt,startTimelineResize:kt,onEditVpFromTimeline:I=>{if(!I)return;let G=rr();G&&Ts({sessionId:G,section:"members",editVpId:I})},onMentionVpFromTimeline:I=>{if(!I)return;let G=A.value;G&&typeof G.appendMention=="function"&&G.appendMention(I)},onCancelVpFromTimeline:I=>{if(!I)return;let G=M(),le=e.yeaftActiveSessionFilter||G?.activeSessionId||null;le&&typeof e.cancelVpTurnForSession=="function"&&e.cancelVpTurnForSession(I,le)},onCancelTaskFromTimeline:I=>!I?.id||!I.sessionId||typeof e.cancelYeaftTask!="function"?!1:e.cancelYeaftTask({agentId:I.agentId,sessionId:I.sessionId,taskId:I.id})}}}});var qy=cm(()=>{Br();ct();Ws();bu();xt();Cu();xu();Mu();Ru();ag();nm();za();Ta();window.Pinia={...Pinia,useChatStore:null,useAuthStore:null};var Oy={components:{LoginPage:Pu,ChatPage:og,YeaftPage:sm},template:`
|
|
8282
8277
|
<div v-if="!authStore.initialized" class="auth-bootstrap" aria-busy="true"><span class="session-loading-spinner"></span></div>
|
|
8283
8278
|
<LoginPage v-else-if="!authStore.isAuthenticated" />
|
|
8284
8279
|
<template v-else>
|
|
8285
8280
|
<YeaftPage v-if="chatStore.currentView === 'yeaft'" />
|
|
8286
8281
|
<ChatPage v-else />
|
|
8287
8282
|
</template>
|
|
8288
|
-
`,setup(){let e=
|
|
8283
|
+
`,setup(){let e=fs(),t=_e();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}}},qi=Vue.createApp(Oy),Hy=Pinia.createPinia();qi.use(Hy);xl(qi,{"zh-CN":Au,en:Tu});Iu();window.Pinia.useChatStore=fs;window.Pinia.useAuthStore=_e;window.Pinia.useVpStore=yt;window.Pinia.useSessionsStore=yu;qi.component("ToolLine",ni);qi.mount("#app")});export default qy();
|