@t0ken.ai/memoryx-openclaw-plugin 2.2.12 → 2.2.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AA4CH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,eAAe,EAAE,KAAK,CAAC;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AA4CD,cAAM,aAAa;IACf,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,WAAW,CAAkB;gBAEzB,YAAY,CAAC,EAAE,YAAY;IAIjC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAad,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA6B1D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IA6B/D,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAYhC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAc1C,KAAK,CAAC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CAAC;IAwBW,cAAc,IAAI,OAAO,CAAC;QACnC,OAAO,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE;YACH,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,UAAU,EAAE,MAAM,CAAC;YACnB,YAAY,EAAE,MAAM,CAAC;YACrB,iBAAiB,EAAE,MAAM,CAAC;YAC1B,gBAAgB,EAAE,MAAM,CAAC;YACzB,mBAAmB,EAAE,MAAM,CAAC;YAC5B,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;SACnB,CAAC;QACF,KAAK,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CAcL;;;;;;kBAUiB,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAoeE;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -143,6 +143,15 @@ class MemoryXPlugin {
143
143
  try {
144
144
  const sdk = await getSDK(this.pluginConfig);
145
145
  const result = await sdk.search(query, limit);
146
+ // Check if quota is limited (search_count >= search_limit for free tier)
147
+ const isLimited = result.is_limited ??
148
+ (result.search_count !== undefined &&
149
+ result.search_limit !== undefined &&
150
+ result.search_count >= result.search_limit);
151
+ // Build upgrade hint if limited
152
+ const upgradeHint = isLimited
153
+ ? `Search quota exceeded (${result.search_count}/${result.search_limit}). Upgrade to Pro for unlimited searches.`
154
+ : undefined;
146
155
  return {
147
156
  memories: (result.data || []).map((m) => ({
148
157
  id: m.id,
@@ -156,8 +165,9 @@ class MemoryXPlugin {
156
165
  category: m.category || "other",
157
166
  score: m.score || 0
158
167
  })),
159
- isLimited: false,
160
- remainingQuota: result.remaining_quota ?? -1
168
+ isLimited,
169
+ remainingQuota: result.remaining_quota ?? -1,
170
+ upgradeHint
161
171
  };
162
172
  }
163
173
  catch (e) {
@@ -603,18 +613,29 @@ export default {
603
613
  }
604
614
  }
605
615
  }, { name: "memoryx_queue_status" });
616
+ // User message capture via message_received hook
617
+ // Event structure: { from: string, content: string, timestamp?: number }
606
618
  api.on("message_received", async (event, ctx) => {
607
619
  const { content } = event;
608
620
  if (content && plugin) {
609
621
  await plugin.onMessage("user", content);
610
622
  }
611
623
  });
612
- api.on("assistant_response", async (event, ctx) => {
613
- const { content } = event;
614
- if (content && plugin) {
615
- await plugin.onMessage("assistant", content);
624
+ // Assistant response capture via llm_output hook
625
+ // Event structure: { assistantTexts: string[], lastAssistant?: unknown, usage?: {...} }
626
+ api.on("llm_output", async (event, ctx) => {
627
+ const { assistantTexts } = event;
628
+ if (assistantTexts && Array.isArray(assistantTexts) && plugin) {
629
+ // Join all assistant text segments
630
+ const fullContent = assistantTexts.join("\n");
631
+ if (fullContent && fullContent.length >= 2) {
632
+ await plugin.onMessage("assistant", fullContent);
633
+ }
616
634
  }
617
635
  });
636
+ // Auto-inject memories via prependContext
637
+ // Note: OpenClaw's systemPrompt field is extracted but NEVER USED (bug in attempt.ts:918-928)
638
+ // We use prependContext which works, but the context will be visible in the user's prompt
618
639
  api.on("before_agent_start", async (event, ctx) => {
619
640
  const { prompt } = event;
620
641
  if (!prompt || prompt.length < 2 || !plugin)
@@ -622,34 +643,37 @@ export default {
622
643
  try {
623
644
  const result = await plugin.recall(prompt, 5);
624
645
  if (result.isLimited) {
646
+ // Don't inject upgrade hints into prompt - just log
625
647
  api.logger.warn(`[MemoryX] ${result.upgradeHint}`);
626
- return {
627
- systemPrompt: `[MemoryX] ${result.upgradeHint}`
628
- };
648
+ return;
629
649
  }
630
650
  if (result.memories.length === 0 && result.relatedMemories.length === 0)
631
651
  return;
632
- // 使用 systemPrompt 而不是 prependContext
633
- // systemPrompt 不会显示在用户聊天内容中
634
- let context = "[MemoryX] Relevant memories from past conversations:\n";
652
+ // Build a concise memory context
653
+ // Format: [Memory Context]\n- memory 1\n- memory 2
654
+ const lines = ["[Memory Context]"];
635
655
  if (result.memories.length > 0) {
636
- context += result.memories.map(m => `- ${m.content}`).join("\n");
656
+ lines.push(...result.memories.map(m => `- ${m.content}`));
637
657
  }
638
658
  if (result.relatedMemories.length > 0) {
639
659
  if (result.memories.length > 0)
640
- context += "\n";
641
- context += result.relatedMemories.map(m => `- ${m.content}`).join("\n");
660
+ lines.push("");
661
+ lines.push("[Related]");
662
+ lines.push(...result.relatedMemories.map(m => `- ${m.content}`));
642
663
  }
643
- api.logger.info(`[MemoryX] Injected ${result.memories.length} direct + ${result.relatedMemories.length} related memories into system prompt`);
664
+ const context = lines.join("\n");
665
+ api.logger.info(`[MemoryX] Injected ${result.memories.length} direct + ${result.relatedMemories.length} related memories`);
644
666
  return {
645
- systemPrompt: context
667
+ prependContext: context
646
668
  };
647
669
  }
648
670
  catch (error) {
649
671
  api.logger.warn(`[MemoryX] Recall failed: ${error}`);
650
672
  }
651
673
  });
652
- api.on("conversation_end", async (event, ctx) => {
674
+ // Session end hook - flush memories when session ends
675
+ // Event structure: { sessionId: string, messageCount: number, durationMs?: number }
676
+ api.on("session_end", async (event, ctx) => {
653
677
  if (plugin) {
654
678
  await plugin.endConversation();
655
679
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t0ken.ai/memoryx-openclaw-plugin",
3
- "version": "2.2.12",
3
+ "version": "2.2.13",
4
4
  "description": "MemoryX real-time memory capture and recall plugin for OpenClaw (powered by @t0ken.ai/memoryx-sdk)",
5
5
  "type": "module",
6
6
  "author": "MemoryX Team",
@@ -35,6 +35,6 @@
35
35
  "typescript": "^5.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@t0ken.ai/memoryx-sdk": "^1.4.2"
38
+ "@t0ken.ai/memoryx-sdk": "^1.4.3"
39
39
  }
40
40
  }