xiaozuoassistant 0.1.73 → 0.1.74

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.
@@ -62,7 +62,11 @@ export class ShortTermMemory {
62
62
  }
63
63
  async loadSessionsFromDisk() {
64
64
  try {
65
- const data = await fs.readJson(INDEX_FILE);
65
+ // Invalidate cache by reading file directly
66
+ // Use fs.readFile to bypass any potential fs-extra internal caching (though unlikely)
67
+ // and ensure we get fresh data
68
+ const content = await fs.readFile(INDEX_FILE, 'utf-8');
69
+ const data = JSON.parse(content);
66
70
  // Log loaded data count for debugging
67
71
  console.log(`[ShortTermMemory:${this.instanceId}] Loaded ${Array.isArray(data) ? data.length : 0} sessions from disk.`);
68
72
  this.sessions.clear();
@@ -371,8 +375,24 @@ export class ShortTermMemory {
371
375
  await this.loadSessionsFromDisk();
372
376
  sessionMeta = this.sessions.get(sessionId);
373
377
  }
378
+ // 如果仍然没有,尝试直接从 index.json 读取一次,绕过缓存逻辑
374
379
  if (!sessionMeta) {
375
- console.error(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} not found even after reload.`);
380
+ try {
381
+ const content = await fs.readFile(INDEX_FILE, 'utf-8');
382
+ const data = JSON.parse(content);
383
+ const found = Array.isArray(data) ? data.find((m) => m.id === sessionId) : null;
384
+ if (found) {
385
+ console.log(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} found in fresh disk read, recovering...`);
386
+ this.sessions.set(found.id, found);
387
+ sessionMeta = found;
388
+ }
389
+ }
390
+ catch (e) {
391
+ console.error(`[ShortTermMemory:${this.instanceId}] Emergency disk read failed:`, e);
392
+ }
393
+ }
394
+ if (!sessionMeta) {
395
+ console.error(`[ShortTermMemory:${this.instanceId}] Session ${sessionId} not found even after emergency reload.`);
376
396
  throw new Error(`Session ${sessionId} not found`);
377
397
  }
378
398
  const msg = { ...message };
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.73",
5
+ "version": "0.1.74",
6
6
  "author": "mantle.lau",
7
7
  "license": "MIT",
8
8
  "repository": {