mr-memory 2.19.0 → 2.20.0
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/index.ts +24 -5
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -876,7 +876,8 @@ const memoryRouterPlugin = {
|
|
|
876
876
|
.description("Search memories in vault")
|
|
877
877
|
.argument("<query>", "Search query")
|
|
878
878
|
.option("-n, --limit <number>", "Number of results", "5")
|
|
879
|
-
.
|
|
879
|
+
.option("--json", "Output raw JSON response")
|
|
880
|
+
.action(async (query: string, opts: { limit: string; json?: boolean }) => {
|
|
880
881
|
if (!memoryKey) { console.error("Not configured. Run: openclaw mr <key>"); return; }
|
|
881
882
|
const limit = parseInt(opts.limit, 10) || 5;
|
|
882
883
|
try {
|
|
@@ -894,16 +895,31 @@ const memoryRouterPlugin = {
|
|
|
894
895
|
return;
|
|
895
896
|
}
|
|
896
897
|
const data = await res.json() as {
|
|
898
|
+
query: string;
|
|
899
|
+
sessionId: string | null;
|
|
900
|
+
memoryKey: string;
|
|
897
901
|
totalMemories: number;
|
|
898
902
|
tokenCount: number;
|
|
903
|
+
windowBreakdown: Record<string, number>;
|
|
904
|
+
metrics: Record<string, number>;
|
|
899
905
|
memories: Array<{
|
|
906
|
+
id: number;
|
|
900
907
|
content: string;
|
|
901
908
|
score: number;
|
|
902
909
|
window: string;
|
|
903
910
|
timestampHuman: string;
|
|
911
|
+
timestamp: number;
|
|
904
912
|
role: string;
|
|
913
|
+
source: string;
|
|
905
914
|
}>;
|
|
906
915
|
};
|
|
916
|
+
|
|
917
|
+
// Raw JSON output
|
|
918
|
+
if (opts.json) {
|
|
919
|
+
console.log(JSON.stringify(data, null, 2));
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
|
|
907
923
|
if (data.totalMemories === 0) {
|
|
908
924
|
console.log("No results found.");
|
|
909
925
|
return;
|
|
@@ -917,11 +933,14 @@ const memoryRouterPlugin = {
|
|
|
917
933
|
month: "short", day: "numeric", year: "numeric",
|
|
918
934
|
});
|
|
919
935
|
const windowIcon = m.window === "immediate" ? "⚡" : m.window === "short" ? "🔥" : m.window === "long" ? "🧠" : "📚";
|
|
920
|
-
|
|
921
|
-
console.log(`
|
|
922
|
-
|
|
936
|
+
console.log(` ${i + 1}. ${windowIcon} ${score}% | ${m.role} | ${date} | id:${m.id}`);
|
|
937
|
+
console.log(` ${m.content}\n`);
|
|
938
|
+
}
|
|
939
|
+
console.log(` Tokens: ${data.tokenCount} | Windows: ${JSON.stringify(data.windowBreakdown)}`);
|
|
940
|
+
if (data.metrics) {
|
|
941
|
+
const ms = data.metrics;
|
|
942
|
+
console.log(` Latency: ${ms.raceMs ?? ms.totalMs ?? '-'}ms`);
|
|
923
943
|
}
|
|
924
|
-
console.log(` Tokens: ${data.tokenCount}`);
|
|
925
944
|
} catch (err) {
|
|
926
945
|
console.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
927
946
|
}
|