@mobcode/openclaw-plugin 0.1.6 → 0.1.8
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/package.json +1 -1
- package/src/openclaw-session-reader.js +1 -1
- package/src/state-store.js +17 -2
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ async function readSessionMessagesThroughChatHistory(config, sessionKey, logger)
|
|
|
60
60
|
});
|
|
61
61
|
const messages = payload?.messages;
|
|
62
62
|
logger?.info?.(
|
|
63
|
-
`[mobcode-history] chat.history response session=${normalizedSessionKey} sessionId=${String(payload?.sessionId ?? "").trim() || "-"} messages=${Array.isArray(messages) ? messages.length : 0}`,
|
|
63
|
+
`[mobcode-history] chat.history response session=${normalizedSessionKey} sessionId=${String(payload?.sessionId ?? "").trim() || "-"} thinkingLevel=${String(payload?.thinkingLevel ?? "").trim() || "-"} fastMode=${String(payload?.fastMode ?? "").trim() || "-"} verboseLevel=${String(payload?.verboseLevel ?? "").trim() || "-"} messages=${Array.isArray(messages) ? messages.length : 0}`,
|
|
64
64
|
);
|
|
65
65
|
return Array.isArray(messages) ? messages : [];
|
|
66
66
|
}
|
package/src/state-store.js
CHANGED
|
@@ -811,14 +811,23 @@ export class MobcodeStateStore {
|
|
|
811
811
|
LIMIT 1`,
|
|
812
812
|
)
|
|
813
813
|
.get(normalizedSessionKey);
|
|
814
|
+
const messageCountRow = this._db()
|
|
815
|
+
.prepare(`SELECT COUNT(*) AS count FROM messages WHERE session_key=?`)
|
|
816
|
+
.get(normalizedSessionKey);
|
|
817
|
+
const messageRows = Number(messageCountRow?.count ?? 0);
|
|
814
818
|
const alreadyBackfilled =
|
|
815
819
|
typeof existing?.last_backfill_at === "string" && existing.last_backfill_at.trim().length > 0;
|
|
816
|
-
if (alreadyBackfilled) {
|
|
820
|
+
if (alreadyBackfilled && messageRows > 0) {
|
|
817
821
|
this.logger?.info?.(
|
|
818
|
-
`[mobcode-store] ensureSessionIndexed skip session=${normalizedSessionKey} reason=already_backfilled`,
|
|
822
|
+
`[mobcode-store] ensureSessionIndexed skip session=${normalizedSessionKey} reason=already_backfilled lastBackfillAt=${existing?.last_backfill_at ?? "-"} messageRows=${messageRows}`,
|
|
819
823
|
);
|
|
820
824
|
return;
|
|
821
825
|
}
|
|
826
|
+
if (alreadyBackfilled && messageRows <= 0) {
|
|
827
|
+
this.logger?.warn?.(
|
|
828
|
+
`[mobcode-store] ensureSessionIndexed retry session=${normalizedSessionKey} reason=stale_backfill_marker lastBackfillAt=${existing?.last_backfill_at ?? "-"} messageRows=${messageRows}`,
|
|
829
|
+
);
|
|
830
|
+
}
|
|
822
831
|
this.logger?.info?.(
|
|
823
832
|
`[mobcode-store] ensureSessionIndexed start session=${normalizedSessionKey}`,
|
|
824
833
|
);
|
|
@@ -993,6 +1002,9 @@ export class MobcodeStateStore {
|
|
|
993
1002
|
ORDER BY id ASC`,
|
|
994
1003
|
)
|
|
995
1004
|
.all(normalizedSessionKey);
|
|
1005
|
+
this.logger?.info?.(
|
|
1006
|
+
`[mobcode-store] pageTranscriptMessages session=${normalizedSessionKey} rows=${rows.length}`,
|
|
1007
|
+
);
|
|
996
1008
|
return rows.map((row) => {
|
|
997
1009
|
const message = fromJson(row.raw_json, {});
|
|
998
1010
|
if (message && typeof message === "object" && !Array.isArray(message) && !message.id) {
|
|
@@ -1009,6 +1021,9 @@ export class MobcodeStateStore {
|
|
|
1009
1021
|
typeof beforeId === "number" && Number.isFinite(beforeId) ? beforeId : null;
|
|
1010
1022
|
const transcriptMessages = await this.pageTranscriptMessages(normalizedSessionKey);
|
|
1011
1023
|
const projected = projectConversationMessages(transcriptMessages, normalizedSessionKey);
|
|
1024
|
+
this.logger?.info?.(
|
|
1025
|
+
`[mobcode-store] pageSessionMessages session=${normalizedSessionKey} transcriptMessages=${transcriptMessages.length} projectedMessages=${projected.length} limit=${normalizedLimit} beforeId=${normalizedBeforeId ?? "-"}`
|
|
1026
|
+
);
|
|
1012
1027
|
const endExclusive = normalizedBeforeId == null
|
|
1013
1028
|
? projected.length
|
|
1014
1029
|
: Math.max(0, Math.min(projected.length, normalizedBeforeId - 1));
|