refactor: unify agent session persistence

This commit is contained in:
2026-06-04 15:02:27 +08:00
parent 04ded0ceb0
commit 0ecb2babf3
22 changed files with 542 additions and 497 deletions
+6 -6
View File
@@ -42,15 +42,15 @@ export class MemoryStore {
constructor(
private readonly baseDir = config.MEMORY_STORAGE_DIR,
private readonly historyDir = join(config.PERSISTENCE_HISTORY_DIR, "memory"),
private readonly backupDir = join(config.PERSISTENCE_BACKUP_DIR, "memory"),
) {}
async initialize() {
await ensureDirectory(this.baseDir);
await ensureDirectory(join(this.baseDir, "users"));
await ensureDirectory(join(this.baseDir, "workspaces"));
// 历史备份与正式数据分目录存放,便于排查和手工恢复。
await ensureDirectory(this.historyDir);
// 备份与正式数据分目录存放,便于排查和手工恢复。
await ensureDirectory(this.backupDir);
}
async upsert(scope: MemoryScope, key: string, draft: MemoryDraft) {
@@ -76,7 +76,7 @@ export class MemoryStore {
this.filePath(scope, key),
renderMemoryMarkdown(scope, entries),
{
historyDir: this.historyDir,
backupDir: this.backupDir,
rootDir: this.baseDir,
},
);
@@ -113,7 +113,7 @@ export class MemoryStore {
this.filePath(scope, key),
renderMemoryMarkdown(scope, entries),
{
historyDir: this.historyDir,
backupDir: this.backupDir,
rootDir: this.baseDir,
},
);
@@ -132,7 +132,7 @@ export class MemoryStore {
this.filePath(scope, key),
renderMemoryMarkdown(scope, next),
{
historyDir: this.historyDir,
backupDir: this.backupDir,
rootDir: this.baseDir,
},
);