@mobcode/openclaw-plugin 0.1.2 → 0.1.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mobcode/openclaw-plugin",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "MobCode integration plugin for OpenClaw",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -47,11 +47,17 @@ export function registerMobcodeGatewayMethods({
47
47
  respond(false, { error: "sessionKey required" });
48
48
  return;
49
49
  }
50
+ api.logger?.info?.(
51
+ `[mobcode.messages.page] request sessionKey=${sessionKey} limit=${String(params?.limit ?? "") || "-"} beforeId=${typeof params?.beforeId === "string" && params.beforeId.trim() ? params.beforeId.trim() : "-"}`,
52
+ );
50
53
  await builders.ensureSessionMessages(sessionKey);
51
54
  const page = await store.pageSessionMessages(sessionKey, {
52
55
  limit: params?.limit,
53
56
  beforeId: params?.beforeId,
54
57
  });
58
+ api.logger?.info?.(
59
+ `[mobcode.messages.page] response sessionKey=${sessionKey} count=${page.items.length} total=${page.total} hasMore=${page.hasMore} nextBeforeId=${page.nextBeforeId ?? "-"}`,
60
+ );
55
61
  respond(true, {
56
62
  ok: true,
57
63
  sessionKey: page.sessionKey,
@@ -46,6 +46,9 @@ async function readSessionMessagesThroughChatHistory(config, sessionKey, logger)
46
46
  if (!normalizedSessionKey) {
47
47
  return [];
48
48
  }
49
+ logger?.info?.(
50
+ `[mobcode-history] chat.history request session=${normalizedSessionKey} limit=1000`,
51
+ );
49
52
  const payload = await requestThroughOperatorApprovalsGateway({
50
53
  config,
51
54
  method: "chat.history",
@@ -57,7 +60,7 @@ async function readSessionMessagesThroughChatHistory(config, sessionKey, logger)
57
60
  });
58
61
  const messages = payload?.messages;
59
62
  logger?.info?.(
60
- `[mobcode-history] chat.history session=${normalizedSessionKey} messages=${Array.isArray(messages) ? messages.length : 0}`,
63
+ `[mobcode-history] chat.history response session=${normalizedSessionKey} sessionId=${String(payload?.sessionId ?? "").trim() || "-"} messages=${Array.isArray(messages) ? messages.length : 0}`,
61
64
  );
62
65
  return Array.isArray(messages) ? messages : [];
63
66
  }
@@ -78,6 +81,9 @@ export async function readSessionTranscriptMessages(config, sessionKey, logger)
78
81
  );
79
82
  // Fall back to adjacent-source runtime imports for development checkouts.
80
83
  }
84
+ logger?.info?.(
85
+ `[mobcode-history] falling back to internal transcript reader session=${String(sessionKey ?? "").trim()}`,
86
+ );
81
87
  const internalMessages = await readSessionTranscriptMessagesFromInternals(sessionKey);
82
88
  logger?.info?.(
83
89
  `[mobcode-history] internal fallback session=${String(sessionKey ?? "").trim()} messages=${internalMessages.length}`,
@@ -39,8 +39,14 @@ export function registerMobcodeRuntimeObservers({ api, store, pluginConfig }) {
39
39
  await store.init();
40
40
 
41
41
  api.runtime.events.onSessionTranscriptUpdate(async (update) => {
42
+ api.logger?.info?.(
43
+ `[mobcode-runtime] transcript update sessionKey=${String(update?.sessionKey ?? "").trim() || "-"} sessionFile=${String(update?.sessionFile ?? "").trim() || "-"} messageId=${String(update?.messageId ?? "").trim() || "-"} hasMessage=${update?.message !== undefined}`,
44
+ );
42
45
  if (retainMessages && update?.message !== undefined) {
43
- await store.appendMessage(update);
46
+ const indexed = await store.appendMessage(update);
47
+ api.logger?.info?.(
48
+ `[mobcode-runtime] transcript indexed sessionKey=${indexed?.sessionKey ?? "-"} total=${String(indexed?.count ?? 0)}`,
49
+ );
44
50
  }
45
51
  if (pushEnabled) {
46
52
  await store.enqueuePush(createPushPayloadFromTranscript(update));
@@ -814,9 +814,18 @@ export class MobcodeStateStore {
814
814
  const alreadyBackfilled =
815
815
  typeof existing?.last_backfill_at === "string" && existing.last_backfill_at.trim().length > 0;
816
816
  if (alreadyBackfilled) {
817
+ this.logger?.info?.(
818
+ `[mobcode-store] ensureSessionIndexed skip session=${normalizedSessionKey} reason=already_backfilled`,
819
+ );
817
820
  return;
818
821
  }
822
+ this.logger?.info?.(
823
+ `[mobcode-store] ensureSessionIndexed start session=${normalizedSessionKey}`,
824
+ );
819
825
  const messages = Array.isArray(loader) ? loader : await loader();
826
+ this.logger?.info?.(
827
+ `[mobcode-store] ensureSessionIndexed loader_result session=${normalizedSessionKey} messages=${Array.isArray(messages) ? messages.length : 0}`,
828
+ );
820
829
  await this.indexSessionMessages(normalizedSessionKey, messages);
821
830
  const now = new Date().toISOString();
822
831
  this._db()
@@ -828,11 +837,17 @@ export class MobcodeStateStore {
828
837
  updated_at=excluded.updated_at`,
829
838
  )
830
839
  .run(normalizedSessionKey, now, now);
840
+ this.logger?.info?.(
841
+ `[mobcode-store] ensureSessionIndexed complete session=${normalizedSessionKey}`,
842
+ );
831
843
  }
832
844
 
833
845
  async indexSessionMessages(sessionKey, messages) {
834
846
  const normalizedSessionKey = String(sessionKey ?? "").trim();
835
847
  if (!normalizedSessionKey || !Array.isArray(messages) || messages.length == 0) {
848
+ this.logger?.info?.(
849
+ `[mobcode-store] indexSessionMessages noop session=${normalizedSessionKey || "-"} messages=${Array.isArray(messages) ? messages.length : 0}`,
850
+ );
836
851
  return;
837
852
  }
838
853
 
@@ -934,6 +949,9 @@ export class MobcodeStateStore {
934
949
  async appendMessage(update) {
935
950
  const sessionKey = normalizeSessionKey(update?.sessionKey, update?.sessionFile);
936
951
  const normalizedMessage = normalizeMessageObject(update?.message, update?.messageId);
952
+ this.logger?.info?.(
953
+ `[mobcode-store] appendMessage sessionKey=${sessionKey} rawSessionKey=${String(update?.sessionKey ?? "").trim() || "-"} sessionFile=${String(update?.sessionFile ?? "").trim() || "-"} messageId=${String(update?.messageId ?? normalizedMessage?.id ?? "").trim() || "-"} role=${String(normalizedMessage?.role ?? "").trim() || "-"}`,
954
+ );
937
955
  await this.indexSessionMessages(sessionKey, [normalizedMessage]);
938
956
  const row = this._db()
939
957
  .prepare(`SELECT COUNT(*) AS count FROM messages WHERE session_key=?`)