@t0ken.ai/memoryx-openclaw-plugin 1.1.15 → 1.1.16
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +226 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,8 @@ declare class MemoryXPlugin {
|
|
|
81
81
|
onMessage(role: string, content: string): Promise<boolean>;
|
|
82
82
|
recall(query: string, limit?: number): Promise<RecallResult>;
|
|
83
83
|
endConversation(): Promise<void>;
|
|
84
|
+
forget(memoryId: string): Promise<boolean>;
|
|
85
|
+
list(limit?: number): Promise<any[]>;
|
|
84
86
|
getStatus(): Promise<{
|
|
85
87
|
initialized: boolean;
|
|
86
88
|
hasApiKey: boolean;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAqDH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAiBD,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;AA0JD,cAAM,mBAAmB;IACrB,OAAO,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AI,CAAC,KAAK,GAAE,MAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAuCxC,SAAS,IAAI,OAAO,CAAC;QAC9B,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,kBAAkB,EAAE;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,cAAc,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAA;KACvF,CAAC;CAQL;;;;;;kBAUiB,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAyQE;AAEF,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -491,6 +491,66 @@ class MemoryXPlugin {
|
|
|
491
491
|
this.conversationManager.startNewConversation();
|
|
492
492
|
log("Conversation ended, starting new conversation");
|
|
493
493
|
}
|
|
494
|
+
async forget(memoryId) {
|
|
495
|
+
this.init();
|
|
496
|
+
if (!this.config.apiKey) {
|
|
497
|
+
log("Forget failed: no API key");
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
try {
|
|
501
|
+
const response = await fetch(`${this.apiBase}/v1/memories/${memoryId}`, {
|
|
502
|
+
method: "DELETE",
|
|
503
|
+
headers: {
|
|
504
|
+
"X-API-Key": this.config.apiKey
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
if (response.ok) {
|
|
508
|
+
log(`Forgot memory ${memoryId}`);
|
|
509
|
+
return true;
|
|
510
|
+
}
|
|
511
|
+
log(`Forget failed: ${response.status}`);
|
|
512
|
+
return false;
|
|
513
|
+
}
|
|
514
|
+
catch (e) {
|
|
515
|
+
log(`Forget failed: ${e}`);
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async list(limit = 10) {
|
|
520
|
+
this.init();
|
|
521
|
+
if (!this.config.apiKey) {
|
|
522
|
+
log("List failed: no API key");
|
|
523
|
+
return [];
|
|
524
|
+
}
|
|
525
|
+
try {
|
|
526
|
+
const response = await fetch(`${this.apiBase}/v1/memories/search`, {
|
|
527
|
+
method: "POST",
|
|
528
|
+
headers: {
|
|
529
|
+
"Content-Type": "application/json",
|
|
530
|
+
"X-API-Key": this.config.apiKey
|
|
531
|
+
},
|
|
532
|
+
body: JSON.stringify({
|
|
533
|
+
query: "*",
|
|
534
|
+
project_id: this.config.projectId,
|
|
535
|
+
limit
|
|
536
|
+
})
|
|
537
|
+
});
|
|
538
|
+
if (!response.ok) {
|
|
539
|
+
log(`List failed: ${response.status}`);
|
|
540
|
+
return [];
|
|
541
|
+
}
|
|
542
|
+
const data = await response.json();
|
|
543
|
+
return (data.data || []).map((m) => ({
|
|
544
|
+
id: m.id,
|
|
545
|
+
content: m.memory || m.content,
|
|
546
|
+
category: m.category || "other"
|
|
547
|
+
}));
|
|
548
|
+
}
|
|
549
|
+
catch (e) {
|
|
550
|
+
log(`List failed: ${e}`);
|
|
551
|
+
return [];
|
|
552
|
+
}
|
|
553
|
+
}
|
|
494
554
|
async getStatus() {
|
|
495
555
|
const status = await this.conversationManager.getStatus();
|
|
496
556
|
return {
|
|
@@ -504,7 +564,7 @@ let plugin;
|
|
|
504
564
|
export default {
|
|
505
565
|
id: "memoryx-openclaw-plugin",
|
|
506
566
|
name: "MemoryX Realtime Plugin",
|
|
507
|
-
version: "1.
|
|
567
|
+
version: "1.1.16",
|
|
508
568
|
description: "Real-time memory capture and recall for OpenClaw",
|
|
509
569
|
register(api, pluginConfig) {
|
|
510
570
|
api.logger.info("[MemoryX] Plugin registering...");
|
|
@@ -512,6 +572,171 @@ export default {
|
|
|
512
572
|
api.logger.info(`[MemoryX] API Base: \`${pluginConfig.apiBaseUrl}\``);
|
|
513
573
|
}
|
|
514
574
|
plugin = new MemoryXPlugin(pluginConfig);
|
|
575
|
+
api.registerTool({
|
|
576
|
+
name: "memoryx_recall",
|
|
577
|
+
label: "MemoryX Recall",
|
|
578
|
+
description: "Search through long-term memories. Use when you need context about user preferences, past decisions, or previously discussed topics.",
|
|
579
|
+
parameters: {
|
|
580
|
+
type: "object",
|
|
581
|
+
properties: {
|
|
582
|
+
query: {
|
|
583
|
+
type: "string",
|
|
584
|
+
description: "Search query to find relevant memories"
|
|
585
|
+
},
|
|
586
|
+
limit: {
|
|
587
|
+
type: "number",
|
|
588
|
+
description: "Maximum number of results to return (default: 5)"
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
required: ["query"]
|
|
592
|
+
},
|
|
593
|
+
async execute(_toolCallId, params) {
|
|
594
|
+
const { query, limit = 5 } = params;
|
|
595
|
+
if (!plugin) {
|
|
596
|
+
return {
|
|
597
|
+
content: [{ type: "text", text: "MemoryX plugin not initialized." }],
|
|
598
|
+
details: { error: "not_initialized" }
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
try {
|
|
602
|
+
const result = await plugin.recall(query, limit);
|
|
603
|
+
if (result.isLimited) {
|
|
604
|
+
return {
|
|
605
|
+
content: [{ type: "text", text: result.upgradeHint || "Quota exceeded" }],
|
|
606
|
+
details: { error: "quota_exceeded", hint: result.upgradeHint }
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
if (result.memories.length === 0 && result.relatedMemories.length === 0) {
|
|
610
|
+
return {
|
|
611
|
+
content: [{ type: "text", text: "No relevant memories found." }],
|
|
612
|
+
details: { count: 0 }
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
const lines = [];
|
|
616
|
+
const total = result.memories.length + result.relatedMemories.length;
|
|
617
|
+
if (result.memories.length > 0) {
|
|
618
|
+
lines.push(`Found ${result.memories.length} direct memories:`);
|
|
619
|
+
result.memories.forEach((m, i) => {
|
|
620
|
+
lines.push(`${i + 1}. [${m.category}] ${m.content} (${Math.round(m.score * 100)}%)`);
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
if (result.relatedMemories.length > 0) {
|
|
624
|
+
if (lines.length > 0)
|
|
625
|
+
lines.push("");
|
|
626
|
+
lines.push(`Found ${result.relatedMemories.length} related memories:`);
|
|
627
|
+
result.relatedMemories.forEach((m, i) => {
|
|
628
|
+
lines.push(`${i + 1}. [${m.category}] ${m.content}`);
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
return {
|
|
632
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
633
|
+
details: {
|
|
634
|
+
count: total,
|
|
635
|
+
direct_count: result.memories.length,
|
|
636
|
+
related_count: result.relatedMemories.length,
|
|
637
|
+
remaining_quota: result.remainingQuota
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
catch (error) {
|
|
642
|
+
return {
|
|
643
|
+
content: [{ type: "text", text: `Memory search failed: ${error.message}` }],
|
|
644
|
+
details: { error: error.message }
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
}, { name: "memoryx_recall" });
|
|
649
|
+
api.registerTool({
|
|
650
|
+
name: "memoryx_forget",
|
|
651
|
+
label: "MemoryX Forget",
|
|
652
|
+
description: "Delete specific memories. Use when user explicitly asks to forget or remove something from memory.",
|
|
653
|
+
parameters: {
|
|
654
|
+
type: "object",
|
|
655
|
+
properties: {
|
|
656
|
+
memory_id: {
|
|
657
|
+
type: "string",
|
|
658
|
+
description: "The ID of the memory to delete"
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
required: ["memory_id"]
|
|
662
|
+
},
|
|
663
|
+
async execute(_toolCallId, params) {
|
|
664
|
+
const { memory_id } = params;
|
|
665
|
+
if (!plugin) {
|
|
666
|
+
return {
|
|
667
|
+
content: [{ type: "text", text: "MemoryX plugin not initialized." }],
|
|
668
|
+
details: { error: "not_initialized" }
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
try {
|
|
672
|
+
const success = await plugin.forget(memory_id);
|
|
673
|
+
if (success) {
|
|
674
|
+
return {
|
|
675
|
+
content: [{ type: "text", text: `Memory ${memory_id} has been forgotten.` }],
|
|
676
|
+
details: { action: "deleted", id: memory_id }
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
return {
|
|
681
|
+
content: [{ type: "text", text: `Memory ${memory_id} not found or could not be deleted.` }],
|
|
682
|
+
details: { action: "failed", id: memory_id }
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
catch (error) {
|
|
687
|
+
return {
|
|
688
|
+
content: [{ type: "text", text: `Failed to forget memory: ${error.message}` }],
|
|
689
|
+
details: { error: error.message }
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}, { name: "memoryx_forget" });
|
|
694
|
+
api.registerTool({
|
|
695
|
+
name: "memoryx_list",
|
|
696
|
+
label: "MemoryX List",
|
|
697
|
+
description: "List all stored memories. Use when user asks what you remember about them.",
|
|
698
|
+
parameters: {
|
|
699
|
+
type: "object",
|
|
700
|
+
properties: {
|
|
701
|
+
limit: {
|
|
702
|
+
type: "number",
|
|
703
|
+
description: "Maximum number of memories to list (default: 10)"
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
},
|
|
707
|
+
async execute(_toolCallId, params) {
|
|
708
|
+
const { limit = 10 } = params;
|
|
709
|
+
if (!plugin) {
|
|
710
|
+
return {
|
|
711
|
+
content: [{ type: "text", text: "MemoryX plugin not initialized." }],
|
|
712
|
+
details: { error: "not_initialized" }
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
try {
|
|
716
|
+
const memories = await plugin.list(limit);
|
|
717
|
+
if (memories.length === 0) {
|
|
718
|
+
return {
|
|
719
|
+
content: [{ type: "text", text: "No memories stored yet." }],
|
|
720
|
+
details: { count: 0 }
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
const lines = [`Here are the ${memories.length} most recent memories:`];
|
|
724
|
+
memories.forEach((m, i) => {
|
|
725
|
+
lines.push(`${i + 1}. [${m.category || 'general'}] ${m.content || m.memory}`);
|
|
726
|
+
});
|
|
727
|
+
return {
|
|
728
|
+
content: [{ type: "text", text: lines.join("\n") }],
|
|
729
|
+
details: { count: memories.length }
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
catch (error) {
|
|
733
|
+
return {
|
|
734
|
+
content: [{ type: "text", text: `Failed to list memories: ${error.message}` }],
|
|
735
|
+
details: { error: error.message }
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}, { name: "memoryx_list" });
|
|
515
740
|
api.on("message_received", async (event, ctx) => {
|
|
516
741
|
const { content } = event;
|
|
517
742
|
if (content && plugin) {
|