@yeaft/webchat-agent 1.0.423 → 1.0.424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/local-runtime/server/handlers/agent-file-terminal.js +18 -0
- package/local-runtime/server/handlers/client-workbench.js +44 -0
- package/local-runtime/version.json +1 -1
- package/local-runtime/web/app.bundle.js +4 -4
- package/local-runtime/web/app.bundle.js.gz +0 -0
- package/local-runtime/web/index.html +1 -1
- package/package.json +1 -1
- package/workbench/file-ops.js +6 -0
|
@@ -137,6 +137,17 @@ async function handleTerminalResponse(agentId, msg, routeKey) {
|
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
async function handleAgentDirectoryPickerResponse(agentId, msg) {
|
|
141
|
+
const pending = consumeWorkbenchRequest({
|
|
142
|
+
agentId,
|
|
143
|
+
requestId: msg._workbenchRequestId,
|
|
144
|
+
responseType: msg.type,
|
|
145
|
+
routeKey: `agent-directory-picker:${agentId}`,
|
|
146
|
+
});
|
|
147
|
+
if (!pending || pending.requestType !== 'agent_directory_picker') return;
|
|
148
|
+
await sendToPendingClient(agentId, msg, pending);
|
|
149
|
+
}
|
|
150
|
+
|
|
140
151
|
async function handleOneShotResponse(agentId, msg, routeKey) {
|
|
141
152
|
const pending = consumeWorkbenchRequest({
|
|
142
153
|
agentId,
|
|
@@ -186,6 +197,13 @@ export async function handleAgentFileTerminal(agentId, agent, rawMsg) {
|
|
|
186
197
|
return true;
|
|
187
198
|
}
|
|
188
199
|
|
|
200
|
+
if (msg.type === 'directory_listing'
|
|
201
|
+
&& msg.conversationId === '_workdir_picker'
|
|
202
|
+
&& msg._workbenchRequestId) {
|
|
203
|
+
await handleAgentDirectoryPickerResponse(agentId, msg);
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
206
|
+
|
|
189
207
|
// `_workbench:` is reserved for Server-authored route conversations. An
|
|
190
208
|
// invalid or cross-Agent value is not a legacy conversation.
|
|
191
209
|
if (typeof msg.conversationId === 'string' && msg.conversationId.startsWith('_workbench:')) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CONFIG } from '../config.js';
|
|
2
|
+
import { agents } from '../context.js';
|
|
2
3
|
import {
|
|
3
4
|
sendToWebClient, forwardToAgent,
|
|
4
5
|
verifyConversationOwnership, getCachedDir
|
|
@@ -37,6 +38,8 @@ async function denyWorkbenchRoute(client, msg) {
|
|
|
37
38
|
await sendToWebClient(client, { type: 'error', message: 'Invalid Workbench Session route' });
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
const AGENT_DIRECTORY_PICKER_CONVERSATION = '_workdir_picker';
|
|
42
|
+
|
|
40
43
|
const RESPONSE_TYPES = Object.freeze({
|
|
41
44
|
terminal_create: ['terminal_created', 'terminal_error'],
|
|
42
45
|
read_file: ['file_content'],
|
|
@@ -248,6 +251,47 @@ export async function handleClientWorkbench(clientId, client, msg, checkAgentAcc
|
|
|
248
251
|
if (!dirAgentId) return;
|
|
249
252
|
if (!await checkAgentAccess(dirAgentId)) return;
|
|
250
253
|
|
|
254
|
+
const isAgentDirectoryPicker = msg.directoryPickerScope === 'agent'
|
|
255
|
+
&& msg.conversationId === AGENT_DIRECTORY_PICKER_CONVERSATION
|
|
256
|
+
&& !msg.workbenchRoute
|
|
257
|
+
&& typeof msg.requestId === 'string'
|
|
258
|
+
&& msg.requestId.length > 0;
|
|
259
|
+
if (isAgentDirectoryPicker) {
|
|
260
|
+
const agent = agents.get(dirAgentId);
|
|
261
|
+
const defaultWorkDir = typeof agent?.workDir === 'string' ? agent.workDir : '';
|
|
262
|
+
const correlationKey = `agent-directory-picker:${dirAgentId}`;
|
|
263
|
+
const internalRequestId = registerWorkbenchRequest({
|
|
264
|
+
agentId: dirAgentId,
|
|
265
|
+
clientId,
|
|
266
|
+
userId: client.userId,
|
|
267
|
+
routeKey: correlationKey,
|
|
268
|
+
conversationId: AGENT_DIRECTORY_PICKER_CONVERSATION,
|
|
269
|
+
workspaceGeneration: correlationKey,
|
|
270
|
+
route: null,
|
|
271
|
+
role: client.role,
|
|
272
|
+
requestType: 'agent_directory_picker',
|
|
273
|
+
expectedResponseTypes: ['directory_listing'],
|
|
274
|
+
publicRequestId: msg.requestId,
|
|
275
|
+
});
|
|
276
|
+
if (!internalRequestId) return;
|
|
277
|
+
const canonical = {
|
|
278
|
+
type: 'list_directory',
|
|
279
|
+
agentId: dirAgentId,
|
|
280
|
+
conversationId: AGENT_DIRECTORY_PICKER_CONVERSATION,
|
|
281
|
+
directoryPickerScope: 'agent',
|
|
282
|
+
dirPath: typeof msg.dirPath === 'string' ? msg.dirPath : defaultWorkDir,
|
|
283
|
+
workDir: defaultWorkDir,
|
|
284
|
+
_workbenchRequestId: internalRequestId,
|
|
285
|
+
};
|
|
286
|
+
try {
|
|
287
|
+
await forwardToAgent(dirAgentId, canonical);
|
|
288
|
+
} catch (error) {
|
|
289
|
+
deleteWorkbenchRequest({ agentId: dirAgentId, requestId: internalRequestId });
|
|
290
|
+
throw error;
|
|
291
|
+
}
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
|
|
251
295
|
const resolved = resolveWorkbenchRequest(client, msg, dirAgentId);
|
|
252
296
|
if (!resolved) {
|
|
253
297
|
await denyWorkbenchRoute(client, msg);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.424"}
|
|
@@ -5229,7 +5229,7 @@ ${String(e||"").trim()}
|
|
|
5229
5229
|
<span class="vp-avatar-typing-dot"></span>
|
|
5230
5230
|
</span>
|
|
5231
5231
|
</span>
|
|
5232
|
-
`,setup(e){let t=Ft(),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 Fr(e){if(!e)return"";let t=String(e).split(/[/\\]/);return t[t.length-1]||t[t.length-2]||e}function So(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 lc=O(()=>{});function Dw(){return kh+=1,`folder-picker-${Date.now()}-${kh}`}var cc,kh,dc,Lw,Sh,uc=O(()=>{cc=()=>({folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",_folderPickerTimer:null,_folderPickerRequestId:null,_folderPickerRequestAgentId:null}),kh=0;dc={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=Dw();this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t,this.chat.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",requestId:s,agentId:t,dirPath:e
|
|
5232
|
+
`,setup(e){let t=Ft(),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 Fr(e){if(!e)return"";let t=String(e).split(/[/\\]/);return t[t.length-1]||t[t.length-2]||e}function So(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 lc=O(()=>{});function Dw(){return kh+=1,`folder-picker-${Date.now()}-${kh}`}var cc,kh,dc,Lw,Sh,uc=O(()=>{cc=()=>({folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",_folderPickerTimer:null,_folderPickerRequestId:null,_folderPickerRequestAgentId:null}),kh=0;dc={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=Dw();this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t,this.chat.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:s,agentId:t,dirPath:e}),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))}},Lw={data(){return cc()},methods:{...dc},mounted(){window.addEventListener("workbench-message",this.handleFolderPickerMessage)},beforeUnmount(){window.removeEventListener("workbench-message",this.handleFolderPickerMessage),this.invalidateFolderPickerRequest()}},Sh=Lw});function $w(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-Ch),a=Math.max(0,i-e.bottom-Ch),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 Ih,Ch,Rn,Io=O(()=>{wh();mo();lc();Dr();pr();uc();Ih="omni",Ch=4;Rn={name:"SessionCreateModal",components:{VpAvatar:bh,ModernSelect:Pn},props:{initialProvider:{type:String,default:"yeaft"},initialAgentId:{type:String,default:null}},emits:["close","created"],template:`
|
|
5233
5233
|
<Teleport to="body">
|
|
5234
5234
|
<div class="modal-overlay" @click.self="onOverlayClick" role="dialog" aria-modal="true" :aria-label="$t('yeaft.session.create.title')">
|
|
5235
5235
|
<div class="modal resume-modal yeaft-session-create-modal">
|
|
@@ -7081,11 +7081,11 @@ ${String(e||"").trim()}
|
|
|
7081
7081
|
<!-- Settings Panel -->
|
|
7082
7082
|
|
|
7083
7083
|
<!-- Folder Picker Dialog -->
|
|
7084
|
-
<div class="folder-picker-overlay" v-if="folderPickerOpen" @click.self="
|
|
7084
|
+
<div class="folder-picker-overlay" v-if="folderPickerOpen" @click.self="closeFolderPicker">
|
|
7085
7085
|
<div class="folder-picker-dialog">
|
|
7086
7086
|
<div class="folder-picker-header">
|
|
7087
7087
|
<span>{{ $t('modal.folderPicker.title') }}</span>
|
|
7088
|
-
<button class="wb-btn-sm" @click="
|
|
7088
|
+
<button class="wb-btn-sm" @click="closeFolderPicker">×</button>
|
|
7089
7089
|
</div>
|
|
7090
7090
|
<div class="folder-picker-path">
|
|
7091
7091
|
<button class="wb-btn-sm" @click="folderPickerNavigateUp" :disabled="!folderPickerPath" :title="$t('modal.folderPicker.parentDir')">
|
|
@@ -7116,7 +7116,7 @@ ${String(e||"").trim()}
|
|
|
7116
7116
|
</div>
|
|
7117
7117
|
</div>
|
|
7118
7118
|
</div>
|
|
7119
|
-
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",unifiedSessionCreateProject:null,convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",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=De().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&&!this.isConversationHidden(e)))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&!this.isConversationHidden(t)&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)).length}},methods:{isConversationHidden(e){return e?.id?(this.store.hiddenSessionCatalog||[]).some(t=>t?.runtimeProvider===(e.provider||"claude-code")&&t?.routeRef?.sessionId===e.id&&t?.routeRef?.agentId===(e.agentId||this.store.currentAgent||null)):!1},onSidebarCollapse(){Eh({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 Sp(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProject=null,this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},onUnifiedCreateInProject({project:e}={}){e?.id&&(this.unifiedSessionCreateProject=e,this.unifiedSessionCreateProvider="yeaft",this.unifiedSessionCreateOpen=!0)},closeUnifiedSessionCreate(){this.unifiedSessionCreateOpen=!1,this.unifiedSessionCreateProject=null},async onUnifiedSessionCreated(e){let t=this.unifiedSessionCreateProject;if(this.closeUnifiedSessionCreate(),!t||!e?.id)return;let s=e.agentId||t.legacyAgentId||this.store.currentAgent||null,n=await this.store.mutateProject?.("move_session",{sessionId:e.id,projectId:t.legacyProjectId||t.id},s);if(!n?.ok){let r=n?.error?.message||n?.error?.code||"unknown";await vt(this.$t("sidebar.projects.assignFailed",{name:t.name,message:r}))}},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"?this.store.hideCatalogSession(t):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 So(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t,{refresh:!0}),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id,{refresh:!0}),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},hideSessionFromSidebar(e){if(!e?.id)return;let t=e.provider||"claude-code";this.store.hideCatalogSession({catalogKey:`chat:${e.id}`,runtimeProvider:t,routeRef:{runtimeProvider:t,agentId:e.agentId||this.store.currentAgent||null,sessionId:e.id},title:this.getConversationTitle(e),workDir:e.workDir||"",agentName:e.agentName||"",availability:e.agentOnline===!1?"offline":"online",pinned:this.store.isSessionPinned(e.id)})},closeSession(e,t){this.store.closeSession(e,t)},async deleteConversation(e,t){await Ee(this.$t("chat.delete.confirm"),{destructive:!0})&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Ro(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Fr(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},async restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Ee(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},async upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;await Ee(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],vt(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],o==="node_incompatible"?vt(this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""})):o==="manual_upgrade_required"?vt(this.$t("chat.agent.manualUpgradeRequired",{version:i||"?"})):vt(`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 Vh(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((f,g)=>{typeof f=="string"&&f&&!u.has(f)&&u.set(f,g)});let p=[];for(let f of Array.isArray(t)?t:[]){if(!f||!f.id||d&&f.agentId&&!d.has(f.agentId))continue;let g=String(f.id),h=f.agentId?`${f.agentId}${g}`:g;p.push({kind:"session",id:g,raw:f,pinned:!!f.pinned||!f.agentId&&u.has(g),active:l?h===a:g===o,processing:!!f.running||!!f.active||!!f.isRunning||!!f.isActive,_manualOrder:Number.isFinite(f.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:Ai(f)})}return p.sort((f,g)=>{if(f.pinned!==g.pinned)return f.pinned?-1:1;if(f._manualOrder!==g._manualOrder)return f._manualOrder-g._manualOrder;if(f._activityTime!==g._activityTime)return g._activityTime-f._activityTime;let h=u.has(f.id)?u.get(f.id):Number.MAX_SAFE_INTEGER,m=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return h!==m?h-m:f.id.localeCompare(g.id)}),p.map(({_manualOrder:f,_activityTime:g,...h})=>h)}var Oh=O(()=>{xi()});var Bw,yx,Hh,Fh=O(()=>{dt();Io();sc();nc();rc();ic();ac();vc();Oh();Bw=3600*1e3,yx=24*Bw,Hh={name:"YeaftSidebar",components:{SessionCreateModal:Rn,SidebarModeToggle:vo,SidebarAgentHeader:yo,SidebarWorkCenter:bo,SessionSidebarShell:wo,UnifiedSessionList:ko},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
7119
|
+
`,data(){return{showAgentDropdown:!1,showSettingsPanel:!1,restartingAgents:{},upgradingAgents:{},showConversationModal:!1,unifiedSessionCreateOpen:!1,unifiedSessionCreateProvider:"yeaft",unifiedSessionCreateProject:null,convModalAgent:"",convModalWorkDir:"",convModalProvider:"claude-code",selectedResumeSession:null,historyLoaded:!1,windowWidth:window.innerWidth,folderPickerOpen:!1,folderPickerPath:"",folderPickerEntries:[],folderPickerLoading:!1,folderPickerSelected:"",folderPickerTarget:"",_folderPickerRequestId:null,_folderPickerRequestAgentId:null,serverVersion:"",chatGroupCollapsed:!1,sidebarTab:"chat",editingChatId:null,editingChatName:"",activeSessionMenu:null}},computed:{store(){return Pinia.useChatStore()},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=De().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&&!this.isConversationHidden(e)))},pinnedChatConversations(){let e=this.store.conversations.filter(t=>t.agentOnline!==!1&&!this.isConversationHidden(t)&&this.store.isSessionPinned(t.id));return this.sortByActivity(e)},unpinnedChatConversations(){return this.sortByActivity(this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)&&!this.store.isSessionPinned(e.id)))},chatSessionCount(){return this.store.conversations.filter(e=>e.agentOnline!==!1&&!this.isConversationHidden(e)).length}},methods:{isConversationHidden(e){return e?.id?(this.store.hiddenSessionCatalog||[]).some(t=>t?.runtimeProvider===(e.provider||"claude-code")&&t?.routeRef?.sessionId===e.id&&t?.routeRef?.agentId===(e.agentId||this.store.currentAgent||null)):!1},onSidebarCollapse(){Eh({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 Sp(e)},isCatalogSessionUnread(e){return e?.runtimeProvider!=="yeaft"?!1:this.store.isYeaftSessionUnread(e.routeRef?.sessionId,e.routeRef?.agentId)},onUnifiedCreate(e="yeaft"){this.unifiedSessionCreateProject=null,this.unifiedSessionCreateProvider=["yeaft","copilot","claude-code"].includes(e)?e:"yeaft",this.unifiedSessionCreateOpen=!0},onUnifiedCreateInProject({project:e}={}){e?.id&&(this.unifiedSessionCreateProject=e,this.unifiedSessionCreateProvider="yeaft",this.unifiedSessionCreateOpen=!0)},closeUnifiedSessionCreate(){this.unifiedSessionCreateOpen=!1,this.unifiedSessionCreateProject=null},async onUnifiedSessionCreated(e){let t=this.unifiedSessionCreateProject;if(this.closeUnifiedSessionCreate(),!t||!e?.id)return;let s=e.agentId||t.legacyAgentId||this.store.currentAgent||null,n=await this.store.mutateProject?.("move_session",{sessionId:e.id,projectId:t.legacyProjectId||t.id},s);if(!n?.ok){let r=n?.error?.message||n?.error?.code||"unknown";await vt(this.$t("sidebar.projects.assignFailed",{name:t.name,message:r}))}},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"?this.store.hideCatalogSession(t):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 So(e,this.$t.bind(this))},selectConversation(e,t){this.store.leaveWorkCenter(),this.store.selectConversation(e,t,{refresh:!0}),this.store.closeSessionSidebar()},onSessionClick(e){if(e.agentOnline===!1){this.store.addMessage({type:"system",content:this.$t("chat.session.agentOffline")});return}if(this.store.isSplitMode&&this.store.activePanelId){this.store.leaveWorkCenter(),this.store.setPanelConversation(this.store.activePanelId,e.id,{refresh:!0}),this.store.closeSessionSidebar();return}this.selectConversation(e.id,e.agentId)},hideSessionFromSidebar(e){if(!e?.id)return;let t=e.provider||"claude-code";this.store.hideCatalogSession({catalogKey:`chat:${e.id}`,runtimeProvider:t,routeRef:{runtimeProvider:t,agentId:e.agentId||this.store.currentAgent||null,sessionId:e.id},title:this.getConversationTitle(e),workDir:e.workDir||"",agentName:e.agentName||"",availability:e.agentOnline===!1?"offline":"online",pinned:this.store.isSessionPinned(e.id)})},closeSession(e,t){this.store.closeSession(e,t)},async deleteConversation(e,t){await Ee(this.$t("chat.delete.confirm"),{destructive:!0})&&this.store.deleteConversation(e,t)},getConversationTitle(e){let t=this.store.getConversationTitle(e.id);return t?t.length>30?t.slice(0,30)+"...":t:e.claudeSessionId?e.claudeSessionId.slice(0,8)+"...":e.id.slice(0,8)+"..."},getConversationFullTitle(e){let t=this.store.getConversationTitle(e.id);if(t&&t.length>30)return t},startChatRename(e){this.editingChatId=e.id,this.editingChatName=this.store.customConversationTitles[e.id]||this.store.conversationTitles[e.id]||"",this.$nextTick(()=>{let t=this.$refs.chatRenameInput;if(t){let s=Array.isArray(t)?t[0]:t;s.focus(),s.select()}})},commitChatRename(){if(!this.editingChatId)return;let e=this.editingChatId,t=this.editingChatName.trim();this.editingChatId=null,this.editingChatName="",this.store.renameChatSession(e,t)},cancelChatRename(){this.editingChatId=null,this.editingChatName=""},toggleSessionMenu(e){this.activeSessionMenu=this.activeSessionMenu===e?null:e},closeSessionMenu(){this.activeSessionMenu=null},getConversationTime(e){let s=this.store.executionStatusMap[e.id]?.lastActivity||e.createdAt;if(!s)return"";let n=new Date(s),r=new Date,i=r-n;return i<6e4?this.$t("chat.time.justNow"):i<36e5?this.$t("chat.time.minutesAgo",{count:Math.floor(i/6e4)}):n.toDateString()===r.toDateString()?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):n.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})},providerLabel(e){return e==="copilot"?this.$t("provider.copilot"):e==="claude-code"?this.$t("provider.claudeCode"):e||""},shortenPath(e){return Ro(e)},formatTime(e){return e?new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):""},getLastPathSegment(e){return Fr(e)},getParentPath(e){if(!e)return"";let t=e.split(/[/\\]/);return t.length<=2?"":t.slice(0,-1).join("/")},handleResize(){this.windowWidth=window.innerWidth},async restartAgent(e){let s=this.store.agents.find(n=>n.id===e)?.name||e;await Ee(this.$t("chat.agent.restartConfirm",{name:s}))&&(this.restartingAgents[e]=!0,setTimeout(()=>{delete this.restartingAgents[e]},12e4),this.store.restartAgent(e))},async upgradeAgent(e){let t=this.store.agents.find(n=>n.id===e),s=t?.name||e;await Ee(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))},closeFolderPicker(){this.folderPickerOpen=!1,this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null)},openFolderPicker(e){let t=this.convModalAgent;if(!t)return;this.folderPickerTarget=e,this.folderPickerOpen=!0,this.folderPickerSelected="",this.folderPickerLoading=!0;let s=this.convModalWorkDir,n=this.store.agents.find(a=>a.id===t),r=s||n?.workDir||"";this.folderPickerPath=r,this.folderPickerEntries=[];let i=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=i,this._folderPickerRequestAgentId=t;let o=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:i,agentId:t,dirPath:r})};o(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&o()},5e3)},loadFolderPickerDir(e){let t=this.convModalAgent;if(!t)return;this.folderPickerLoading=!0,this.folderPickerSelected="",this.folderPickerEntries=[];let s=`folder-picker-${Date.now()}-${Math.random().toString(36).slice(2,8)}`;this._folderPickerRequestId=s,this._folderPickerRequestAgentId=t;let n=()=>{this.store.sendWsMessage({type:"list_directory",conversationId:"_workdir_picker",directoryPickerScope:"agent",requestId:s,agentId:t,dirPath:e})};n(),this._folderPickerTimer&&clearTimeout(this._folderPickerTimer),this._folderPickerTimer=setTimeout(()=>{this.folderPickerLoading&&this.folderPickerOpen&&n()},5e3)},folderPickerNavigateUp(){if(!this.folderPickerPath)return;let e=this.folderPickerPath.includes("\\"),t=e?"\\":"/",s=this.folderPickerPath.replace(/[/\\]$/,"").split(/[/\\]/);if(s.pop(),s.length===0)this.folderPickerPath="",this.loadFolderPickerDir("");else if(e&&s.length===1&&/^[A-Za-z]:$/.test(s[0]))this.folderPickerPath=s[0]+"\\",this.loadFolderPickerDir(s[0]+"\\");else{let n=s.join(t);this.folderPickerPath=n,this.loadFolderPickerDir(n)}},folderPickerSelectItem(e){this.folderPickerSelected=e.name},folderPickerEnter(e){let s=this.folderPickerPath.includes("\\")||/^[A-Z]:/.test(e.name)?"\\":"/",n;this.folderPickerPath?n=this.folderPickerPath.replace(/[/\\]$/,"")+s+e.name:/^[A-Z]:$/.test(e.name)?n=e.name+"\\":n="/"+e.name,this.folderPickerPath=n,this.loadFolderPickerDir(n)},confirmFolderPicker(){let e=this.folderPickerPath;if(e){if(this.folderPickerSelected){let t=e.includes("\\")?"\\":"/";e=e.replace(/[/\\]$/,"")+t+this.folderPickerSelected}this.convModalWorkDir=e,this.selectedResumeSession=null,this.convModalAgent&&(this.store.listHistorySessionsForAgent(this.convModalAgent,e,this.convModalProvider),this.historyLoaded=!0),this.closeFolderPicker()}},handleFolderPickerMessage(e){let t=e.detail;!t||t.type!=="directory_listing"||t.conversationId!=="_workdir_picker"||!this.folderPickerOpen||!this._folderPickerRequestId||t.requestId!==this._folderPickerRequestId||this.convModalAgent!==this._folderPickerRequestAgentId||(this._folderPickerTimer&&(clearTimeout(this._folderPickerTimer),this._folderPickerTimer=null),this._folderPickerRequestId=null,this._folderPickerRequestAgentId=null,this.folderPickerLoading=!1,this.folderPickerEntries=(t.entries||[]).filter(s=>s.type==="directory").sort((s,n)=>s.name.localeCompare(n.name)),t.dirPath!=null&&(this.folderPickerPath=t.dirPath))}},mounted(){if(this.store.openUnifiedChatCreate){let e=this.store.openUnifiedChatCreate;this.store.openUnifiedChatCreate=!1,this.convModalProvider=e==="copilot"?"copilot":"claude-code",this.openConversationModal({preserveProvider:!0})}this._clickOutsideHandler=e=>{e.target.closest(".agent-selector")||(this.showAgentDropdown=!1),!e.target.closest(".session-dots-btn")&&!e.target.closest(".session-menu")&&(this.activeSessionMenu=null)},document.addEventListener("click",this._clickOutsideHandler),window.addEventListener("resize",this.handleResize),window.addEventListener("workbench-message",this.handleFolderPickerMessage),fetch("/api/version").then(e=>e.json()).then(e=>{this.serverVersion=e.version}).catch(()=>{}),this._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],vt(this.$t("chat.agent.alreadyLatest",{version:i||""}))):(delete this.upgradingAgents[t],o==="node_incompatible"?vt(this.$t("chat.agent.nodeIncompatible",{current:a||"?",required:l||"?",version:i||""})):o==="manual_upgrade_required"?vt(this.$t("chat.agent.manualUpgradeRequired",{version:i||"?"})):vt(`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 Vh(e={}){let{sessions:t,activeSessionId:s,activeSessionKey:n,pinnedSessionIds:r,onlineAgentIds:i}=e,o=s||null,a=n||null,l=Object.prototype.hasOwnProperty.call(e,"activeSessionKey"),c=Array.isArray(r)?r:[],d=Array.isArray(i)?new Set(i.filter(Boolean)):null,u=new Map;c.forEach((f,g)=>{typeof f=="string"&&f&&!u.has(f)&&u.set(f,g)});let p=[];for(let f of Array.isArray(t)?t:[]){if(!f||!f.id||d&&f.agentId&&!d.has(f.agentId))continue;let g=String(f.id),h=f.agentId?`${f.agentId}${g}`:g;p.push({kind:"session",id:g,raw:f,pinned:!!f.pinned||!f.agentId&&u.has(g),active:l?h===a:g===o,processing:!!f.running||!!f.active||!!f.isRunning||!!f.isActive,_manualOrder:Number.isFinite(f.sortOrder)?f.sortOrder:Number.MAX_SAFE_INTEGER,_activityTime:Ai(f)})}return p.sort((f,g)=>{if(f.pinned!==g.pinned)return f.pinned?-1:1;if(f._manualOrder!==g._manualOrder)return f._manualOrder-g._manualOrder;if(f._activityTime!==g._activityTime)return g._activityTime-f._activityTime;let h=u.has(f.id)?u.get(f.id):Number.MAX_SAFE_INTEGER,m=u.has(g.id)?u.get(g.id):Number.MAX_SAFE_INTEGER;return h!==m?h-m:f.id.localeCompare(g.id)}),p.map(({_manualOrder:f,_activityTime:g,...h})=>h)}var Oh=O(()=>{xi()});var Bw,yx,Hh,Fh=O(()=>{dt();Io();sc();nc();rc();ic();ac();vc();Oh();Bw=3600*1e3,yx=24*Bw,Hh={name:"YeaftSidebar",components:{SessionCreateModal:Rn,SidebarModeToggle:vo,SidebarAgentHeader:yo,SidebarWorkCenter:bo,SessionSidebarShell:wo,UnifiedSessionList:ko},emits:["select-group","select-chat","toggle-sidebar","back","open-settings","open-group-settings"],template:`
|
|
7120
7120
|
<SessionSidebarShell class="yeaft-sidebar" :collapsed="collapsed">
|
|
7121
7121
|
<template #collapsed>
|
|
7122
7122
|
<!-- Collapsed Icon Bar \u2014 mirrors Chat's .sidebar-collapsed-bar so the
|
|
Binary file
|
package/package.json
CHANGED
package/workbench/file-ops.js
CHANGED
|
@@ -120,6 +120,7 @@ export async function handleWriteFile(msg) {
|
|
|
120
120
|
|
|
121
121
|
export async function handleListDirectory(msg) {
|
|
122
122
|
const { conversationId, requestId, dirPath, _requestUserId, _requestClientId } = msg;
|
|
123
|
+
const directoryPickerScope = msg.directoryPickerScope === 'agent' ? 'agent' : undefined;
|
|
123
124
|
const conv = ctx.conversations.get(conversationId);
|
|
124
125
|
const workDir = msg.workDir || conv?.workDir || ctx.CONFIG.workDir;
|
|
125
126
|
|
|
@@ -137,6 +138,7 @@ export async function handleListDirectory(msg) {
|
|
|
137
138
|
sendWorkbenchResult(ctx, msg, {
|
|
138
139
|
type: 'directory_listing',
|
|
139
140
|
conversationId,
|
|
141
|
+
...(directoryPickerScope ? { directoryPickerScope } : {}),
|
|
140
142
|
requestId,
|
|
141
143
|
_requestUserId,
|
|
142
144
|
_requestClientId,
|
|
@@ -154,6 +156,7 @@ export async function handleListDirectory(msg) {
|
|
|
154
156
|
sendWorkbenchResult(ctx, msg, {
|
|
155
157
|
type: 'directory_listing',
|
|
156
158
|
conversationId,
|
|
159
|
+
...(directoryPickerScope ? { directoryPickerScope } : {}),
|
|
157
160
|
requestId,
|
|
158
161
|
_requestUserId,
|
|
159
162
|
_requestClientId,
|
|
@@ -165,6 +168,7 @@ export async function handleListDirectory(msg) {
|
|
|
165
168
|
sendWorkbenchResult(ctx, msg, {
|
|
166
169
|
type: 'directory_listing',
|
|
167
170
|
conversationId,
|
|
171
|
+
...(directoryPickerScope ? { directoryPickerScope } : {}),
|
|
168
172
|
requestId,
|
|
169
173
|
_requestUserId,
|
|
170
174
|
_requestClientId,
|
|
@@ -213,6 +217,7 @@ export async function handleListDirectory(msg) {
|
|
|
213
217
|
sendWorkbenchResult(ctx, msg, {
|
|
214
218
|
type: 'directory_listing',
|
|
215
219
|
conversationId,
|
|
220
|
+
...(directoryPickerScope ? { directoryPickerScope } : {}),
|
|
216
221
|
requestId,
|
|
217
222
|
_requestUserId,
|
|
218
223
|
_requestClientId,
|
|
@@ -223,6 +228,7 @@ export async function handleListDirectory(msg) {
|
|
|
223
228
|
sendWorkbenchResult(ctx, msg, {
|
|
224
229
|
type: 'directory_listing',
|
|
225
230
|
conversationId,
|
|
231
|
+
...(directoryPickerScope ? { directoryPickerScope } : {}),
|
|
226
232
|
requestId,
|
|
227
233
|
_requestUserId,
|
|
228
234
|
_requestClientId,
|