agent-memory-graph 0.4.0 → 0.4.1
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/plugin/entry.js +27 -11
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/plugin/entry.js
CHANGED
|
@@ -5781,24 +5781,40 @@ var entry_default = definePluginEntry({
|
|
|
5781
5781
|
if (config?.promptInjection === false) return;
|
|
5782
5782
|
try {
|
|
5783
5783
|
const graph = await getGraph(config);
|
|
5784
|
-
const prompt = event.prompt || "";
|
|
5785
5784
|
const stats = graph.stats();
|
|
5786
5785
|
if (stats.entities === 0) return;
|
|
5786
|
+
const prompt = event.prompt || "";
|
|
5787
5787
|
let contextLines = [];
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5788
|
+
const PRIORITY_TYPES = ["Project", "Person", "Platform", "Organization", "Company", "Event", "System"];
|
|
5789
|
+
const SKIP_TYPES = ["Tool", "Concept", "File", "Award"];
|
|
5790
|
+
if (prompt && prompt.length > 20) {
|
|
5791
|
+
const searchQuery = prompt.slice(0, 100).replace(/[\n\r]+/g, " ").trim();
|
|
5792
|
+
const results = graph.search(searchQuery, 15);
|
|
5791
5793
|
if (results.length > 0) {
|
|
5792
|
-
|
|
5793
|
-
const
|
|
5794
|
-
|
|
5795
|
-
|
|
5794
|
+
const filtered = results.filter((r) => !SKIP_TYPES.includes(r.entity.type)).sort((a, b) => {
|
|
5795
|
+
const aPriority = PRIORITY_TYPES.indexOf(a.entity.type);
|
|
5796
|
+
const bPriority = PRIORITY_TYPES.indexOf(b.entity.type);
|
|
5797
|
+
const aScore = (aPriority >= 0 ? 100 - aPriority : 50) + (a.relations?.length || 0);
|
|
5798
|
+
const bScore = (bPriority >= 0 ? 100 - bPriority : 50) + (b.relations?.length || 0);
|
|
5799
|
+
return bScore - aScore;
|
|
5800
|
+
}).slice(0, 5);
|
|
5801
|
+
if (filtered.length > 0) {
|
|
5802
|
+
contextLines = filtered.map((r) => {
|
|
5803
|
+
const rels = r.relations?.filter((rel) => !SKIP_TYPES.includes(rel.targetType || "")).slice(0, 3).map((rel) => `${rel.direction === "outgoing" ? "\u2192" : "\u2190"} ${rel.relation} ${rel.target}`).join(", ") || "";
|
|
5804
|
+
return `${r.entity.name} (${r.entity.type})${rels ? ": " + rels : ""}`;
|
|
5805
|
+
});
|
|
5806
|
+
}
|
|
5796
5807
|
}
|
|
5797
5808
|
}
|
|
5798
5809
|
if (contextLines.length === 0) {
|
|
5799
|
-
const
|
|
5800
|
-
|
|
5801
|
-
|
|
5810
|
+
const allEntities = graph.listEntities({ limit: 30, sortBy: "updated_at" });
|
|
5811
|
+
const prioritized = allEntities.filter((e) => !SKIP_TYPES.includes(e.type)).sort((a, b) => {
|
|
5812
|
+
const aPriority = PRIORITY_TYPES.indexOf(a.type);
|
|
5813
|
+
const bPriority = PRIORITY_TYPES.indexOf(b.type);
|
|
5814
|
+
return (bPriority >= 0 ? bPriority : -1) - (aPriority >= 0 ? aPriority : -1);
|
|
5815
|
+
}).slice(0, 5);
|
|
5816
|
+
if (prioritized.length > 0) {
|
|
5817
|
+
contextLines = prioritized.map((e) => `${e.name} (${e.type})`);
|
|
5802
5818
|
}
|
|
5803
5819
|
}
|
|
5804
5820
|
if (contextLines.length === 0) return;
|
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-memory-graph",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Domain-agnostic knowledge graph memory for AI agents. Zero-config, local-first, SQLite-powered. Works as OpenClaw skill (CLI) or plugin (auto-hook).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/src/index.js",
|