@hienlh/ppm 0.9.43 → 0.9.45
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.45] - 2026-04-06
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- **Identity lost on server restart**: Identity save ran AFTER `streamToTelegram()` — if streaming timed out, the save was skipped. Moved identity persistence to before streaming so it writes to SQLite immediately.
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
- **Restart notification includes version**: `/restart` now sends "PPM v0.9.45 restarted successfully" instead of generic message.
|
|
10
|
+
|
|
3
11
|
## [0.9.42] - 2026-04-06
|
|
4
12
|
|
|
5
13
|
### Changed
|
package/package.json
CHANGED
|
@@ -41,6 +41,9 @@ class PPMBotService {
|
|
|
41
41
|
/** Chat IDs that just received identity onboarding prompt */
|
|
42
42
|
private identityPending = new Set<string>();
|
|
43
43
|
|
|
44
|
+
/** Chat IDs where we've already checked for identity (once per session) */
|
|
45
|
+
private hasCheckedIdentity = new Set<string>();
|
|
46
|
+
|
|
44
47
|
/** Message count per session for periodic memory save */
|
|
45
48
|
private messageCount = new Map<string, number>();
|
|
46
49
|
|
|
@@ -92,6 +95,7 @@ class PPMBotService {
|
|
|
92
95
|
this.processing.clear();
|
|
93
96
|
this.messageQueue.clear();
|
|
94
97
|
this.identityPending.clear();
|
|
98
|
+
this.hasCheckedIdentity.clear();
|
|
95
99
|
this.messageCount.clear();
|
|
96
100
|
|
|
97
101
|
console.log("[ppmbot] Stopped");
|
|
@@ -403,8 +407,16 @@ class PPMBotService {
|
|
|
403
407
|
// Only notify if restart was recent (< 60s)
|
|
404
408
|
if (Date.now() - data.ts > 60_000) return;
|
|
405
409
|
|
|
410
|
+
// Read version from package.json
|
|
411
|
+
let version = "";
|
|
412
|
+
try {
|
|
413
|
+
const pkgPath = join(import.meta.dir, "../../../package.json");
|
|
414
|
+
const pkg = await Bun.file(pkgPath).json();
|
|
415
|
+
version = pkg.version ? ` v${pkg.version}` : "";
|
|
416
|
+
} catch {}
|
|
417
|
+
|
|
406
418
|
for (const cid of data.chatIds) {
|
|
407
|
-
await this.telegram?.sendMessage(Number(cid),
|
|
419
|
+
await this.telegram?.sendMessage(Number(cid), `✅ PPM${version} restarted successfully.`);
|
|
408
420
|
}
|
|
409
421
|
} catch {}
|
|
410
422
|
}
|
|
@@ -496,6 +508,20 @@ class PPMBotService {
|
|
|
496
508
|
fullMessage = `<system-context>\n${systemPrompt}\n</system-context>\n\n${text}`;
|
|
497
509
|
}
|
|
498
510
|
|
|
511
|
+
// Save identity BEFORE streaming — must persist even if streaming times out
|
|
512
|
+
if (this.identityPending.has(chatId)) {
|
|
513
|
+
this.identityPending.delete(chatId);
|
|
514
|
+
this.memory.saveOne("_global", `User identity: ${text}`, "preference", session.sessionId);
|
|
515
|
+
console.log("[ppmbot] Saved identity memory from onboarding");
|
|
516
|
+
} else if (!this.hasCheckedIdentity.has(chatId)) {
|
|
517
|
+
this.hasCheckedIdentity.add(chatId);
|
|
518
|
+
const globalMems = this.memory.getSummary("_global", 50);
|
|
519
|
+
if (!globalMems.some((m) => m.category === "preference" && /identity/i.test(m.content))) {
|
|
520
|
+
this.memory.saveOne("_global", `User identity: ${text}`, "preference", session.sessionId);
|
|
521
|
+
console.log("[ppmbot] Saved identity memory (first message, no identity found)");
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
499
525
|
const events = chatService.sendMessage(
|
|
500
526
|
session.providerId,
|
|
501
527
|
session.sessionId,
|
|
@@ -514,13 +540,6 @@ class PPMBotService {
|
|
|
514
540
|
},
|
|
515
541
|
);
|
|
516
542
|
|
|
517
|
-
// Capture identity if onboarding was just shown
|
|
518
|
-
if (this.identityPending.has(chatId)) {
|
|
519
|
-
this.identityPending.delete(chatId);
|
|
520
|
-
this.memory.saveOne("_global", `User identity: ${text}`, "preference", session.sessionId);
|
|
521
|
-
console.log("[ppmbot] Saved identity memory from onboarding");
|
|
522
|
-
}
|
|
523
|
-
|
|
524
543
|
// Periodic memory extraction — fire-and-forget every N messages
|
|
525
544
|
const count = (this.messageCount.get(session.sessionId) ?? 0) + 1;
|
|
526
545
|
this.messageCount.set(session.sessionId, count);
|