xiaozuoassistant 0.1.72 → 0.1.73

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.
@@ -63,6 +63,8 @@ export class ShortTermMemory {
63
63
  async loadSessionsFromDisk() {
64
64
  try {
65
65
  const data = await fs.readJson(INDEX_FILE);
66
+ // Log loaded data count for debugging
67
+ console.log(`[ShortTermMemory:${this.instanceId}] Loaded ${Array.isArray(data) ? data.length : 0} sessions from disk.`);
66
68
  this.sessions.clear();
67
69
  if (Array.isArray(data)) {
68
70
  for (const meta of data) {
@@ -73,7 +75,7 @@ export class ShortTermMemory {
73
75
  }
74
76
  }
75
77
  catch (e) {
76
- console.error('[ShortTermMemory] Failed to load index.json:', e);
78
+ console.error(`[ShortTermMemory:${this.instanceId}] Failed to load index.json:`, e);
77
79
  // 此时保持 sessions 为空或之前的状态
78
80
  }
79
81
  }
@@ -166,11 +168,13 @@ export class ShortTermMemory {
166
168
  const sessionDir = this.getSessionDir(id);
167
169
  await fs.ensureDir(sessionDir);
168
170
  await fs.writeJson(this.getMessagesFile(id), [], { spaces: 2 });
171
+ // IMPORTANT: Reload from disk BEFORE adding new session to avoid overwriting other processes' changes
172
+ await this.loadSessionsFromDisk();
169
173
  // 更新内存
170
174
  this.sessions.set(id, meta);
171
175
  // 异步持久化
172
176
  await this.persistIndex();
173
- console.log(`[ShortTermMemory] Session created: ${id}`);
177
+ console.log(`[ShortTermMemory:${this.instanceId}] Session created and persisted: ${id}`);
174
178
  return { meta, messages: [] };
175
179
  }
176
180
  async listSessions() {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "xiaozuoassistant",
3
3
  "private": false,
4
4
  "description": "Your personal, locally-hosted AI assistant for office productivity.",
5
- "version": "0.1.72",
5
+ "version": "0.1.73",
6
6
  "author": "mantle.lau",
7
7
  "license": "MIT",
8
8
  "repository": {