@bamdra/bamdra-openclaw-memory 0.3.7 → 0.3.9
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/dist/index.js +43 -0
- package/dist/openclaw.plugin.json +1 -1
- package/dist/package.json +3 -3
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -363,6 +363,32 @@ var MemorySqliteStore = class {
|
|
|
363
363
|
record.rawJson
|
|
364
364
|
);
|
|
365
365
|
}
|
|
366
|
+
async backfillSessionIdentity(args) {
|
|
367
|
+
this.db.exec("BEGIN");
|
|
368
|
+
try {
|
|
369
|
+
this.db.prepare(
|
|
370
|
+
`UPDATE ${TABLES.messages}
|
|
371
|
+
SET user_id = COALESCE(user_id, ?),
|
|
372
|
+
channel_type = COALESCE(channel_type, ?),
|
|
373
|
+
sender_open_id = COALESCE(sender_open_id, ?)
|
|
374
|
+
WHERE session_id = ?`
|
|
375
|
+
).run(args.userId, args.channelType ?? null, args.senderOpenId ?? null, args.sessionId);
|
|
376
|
+
this.db.prepare(
|
|
377
|
+
`UPDATE ${TABLES.topics}
|
|
378
|
+
SET user_id = COALESCE(user_id, ?)
|
|
379
|
+
WHERE session_id = ?`
|
|
380
|
+
).run(args.userId, args.sessionId);
|
|
381
|
+
this.db.prepare(
|
|
382
|
+
`UPDATE ${TABLES.sessionState}
|
|
383
|
+
SET user_id = COALESCE(user_id, ?)
|
|
384
|
+
WHERE session_id = ?`
|
|
385
|
+
).run(args.userId, args.sessionId);
|
|
386
|
+
this.db.exec("COMMIT");
|
|
387
|
+
} catch (error) {
|
|
388
|
+
this.db.exec("ROLLBACK");
|
|
389
|
+
throw error;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
366
392
|
async getSessionState(sessionId) {
|
|
367
393
|
const row = this.db.prepare(
|
|
368
394
|
`SELECT session_id, user_id, active_topic_id, last_compacted_at, last_turn_id, updated_at
|
|
@@ -1241,6 +1267,7 @@ function createContextEngineMemoryV2Plugin(inputConfig, api) {
|
|
|
1241
1267
|
async (event) => {
|
|
1242
1268
|
await ensureResolvedIdentity(event);
|
|
1243
1269
|
const sessionId = getSessionIdFromHookContext(event);
|
|
1270
|
+
await backfillResolvedIdentity(store, sessionId);
|
|
1244
1271
|
const text = getTextFromHookContext(event);
|
|
1245
1272
|
logMemoryEvent("hook-ingest-received", {
|
|
1246
1273
|
hasSessionId: Boolean(sessionId),
|
|
@@ -1270,6 +1297,7 @@ function createContextEngineMemoryV2Plugin(inputConfig, api) {
|
|
|
1270
1297
|
registerTypedHook("before_prompt_build", async (event, hookContext) => {
|
|
1271
1298
|
await ensureResolvedIdentity(hookContext);
|
|
1272
1299
|
const sessionId = getSessionIdFromHookContext(hookContext);
|
|
1300
|
+
await backfillResolvedIdentity(store, sessionId);
|
|
1273
1301
|
const text = getTextFromHookContext(event);
|
|
1274
1302
|
logMemoryEvent("hook-assemble-received", {
|
|
1275
1303
|
hasSessionId: Boolean(sessionId),
|
|
@@ -1682,6 +1710,21 @@ async function ensureResolvedIdentity(context) {
|
|
|
1682
1710
|
});
|
|
1683
1711
|
}
|
|
1684
1712
|
}
|
|
1713
|
+
async function backfillResolvedIdentity(store, sessionId) {
|
|
1714
|
+
if (!sessionId || typeof store.backfillSessionIdentity !== "function") {
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
const userId = getResolvedUserId(sessionId);
|
|
1718
|
+
if (!userId) {
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
await store.backfillSessionIdentity({
|
|
1722
|
+
sessionId,
|
|
1723
|
+
userId,
|
|
1724
|
+
channelType: getResolvedChannelType(sessionId),
|
|
1725
|
+
senderOpenId: getResolvedSenderOpenId(sessionId)
|
|
1726
|
+
});
|
|
1727
|
+
}
|
|
1685
1728
|
function getResolvedUserId(sessionId) {
|
|
1686
1729
|
const identity = getResolvedIdentity(sessionId);
|
|
1687
1730
|
const userId = identity?.userId;
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamdra/bamdra-openclaw-memory",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Unified topic-aware memory plugin for OpenClaw with durable SQLite recall and bounded context growth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.bamdra.com",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@bamdra/bamdra-user-bind": "^0.1.
|
|
63
|
-
"@bamdra/bamdra-memory-vector": "^0.1.
|
|
62
|
+
"@bamdra/bamdra-user-bind": "^0.1.6",
|
|
63
|
+
"@bamdra/bamdra-memory-vector": "^0.1.6"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^24.5.2"
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamdra/bamdra-openclaw-memory",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Unified topic-aware memory plugin for OpenClaw with durable SQLite recall and bounded context growth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.bamdra.com",
|
|
@@ -59,8 +59,8 @@
|
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@bamdra/bamdra-user-bind": "^0.1.
|
|
63
|
-
"@bamdra/bamdra-memory-vector": "^0.1.
|
|
62
|
+
"@bamdra/bamdra-user-bind": "^0.1.6",
|
|
63
|
+
"@bamdra/bamdra-memory-vector": "^0.1.6"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@types/node": "^24.5.2"
|