|
|
@@ -3,7 +3,7 @@
|
|
|
// 路径以"位置 + 相对路径"表示;解析符号链接后必须仍在该位置之内
|
|
|
import fs from 'node:fs'
|
|
|
import path from 'node:path'
|
|
|
-import { desc, eq } from 'drizzle-orm'
|
|
|
+import { eq } from 'drizzle-orm'
|
|
|
import { zipSync } from 'fflate'
|
|
|
import type { AppSettings, FsEntryDto, FsRootDto, FsShortcutDto, KnowledgeRootDto } from '@agent-server/shared'
|
|
|
import { config } from '../config'
|
|
|
@@ -34,15 +34,10 @@ export class FileManagerService {
|
|
|
return this.rootList().map(r => ({ id: r.id, name: r.name, kind: r.kind, writable: r.writable, description: r.description, exists: fs.existsSync(r.path) }))
|
|
|
}
|
|
|
|
|
|
- /** 常用目录:工作区根目录、最近的会话、各资料库、服务目录中的常用子目录 */
|
|
|
+ /** 常用目录:各资料库、服务目录中的常用子目录(会话工作区在"位置"里,不重复列出) */
|
|
|
shortcuts(): FsShortcutDto[] {
|
|
|
const s = this.settings()
|
|
|
- const out: FsShortcutDto[] = [{ label: '全部会话工作区', rootId: 'workspaces', path: '', icon: 'folder-library' }]
|
|
|
- const recent = this.db.select({ id: sessions.id, title: sessions.title, dir: sessions.workspaceDir }).from(sessions).orderBy(desc(sessions.updatedAt)).limit(8).all()
|
|
|
- for (const r of recent) {
|
|
|
- if (!isWithin(r.dir, s.paths.workspaceRoot)) continue
|
|
|
- out.push({ label: r.title || '新会话', rootId: 'workspaces', path: path.relative(s.paths.workspaceRoot, r.dir), icon: 'comment-discussion' })
|
|
|
- }
|
|
|
+ const out: FsShortcutDto[] = []
|
|
|
for (const k of this.knowledge()) if (k.enabled) out.push({ label: k.name, rootId: `kb:${k.id}`, path: '', icon: 'library' })
|
|
|
const server = realpathLoose(config.dataDir)
|
|
|
const dirs: [string, string, string][] = [
|