@wazionapps/openclaw-memory-nexo-brain 1.0.3 → 1.0.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/dist/index.js +105 -92
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18,66 +18,73 @@ const plugin = {
|
|
|
18
18
|
description: "Cognitive memory system — Atkinson-Shiffrin model, semantic RAG, trust scoring, and metacognitive guard.",
|
|
19
19
|
kind: "memory",
|
|
20
20
|
register(api) {
|
|
21
|
-
const config = api.pluginConfig;
|
|
22
|
-
const
|
|
21
|
+
const config = (api.pluginConfig || {});
|
|
22
|
+
const resolvePath = api.resolvePath ? api.resolvePath.bind(api) : (p) => p.replace("~", process.env.HOME || "/root");
|
|
23
|
+
const nexoHome = resolvePath(config.nexoHome || "~/.nexo");
|
|
23
24
|
const pythonPath = config.pythonPath || "python3";
|
|
24
25
|
const autoRecall = config.autoRecall !== false;
|
|
25
26
|
const autoCapture = config.autoCapture !== false;
|
|
26
27
|
const guardEnabled = config.guardEnabled !== false;
|
|
27
28
|
bridge = new McpBridge({ nexoHome, pythonPath });
|
|
28
29
|
// Register the system prompt section that tells the agent about NEXO
|
|
29
|
-
api.registerMemoryPromptSection
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
30
|
+
if (typeof api.registerMemoryPromptSection === "function") {
|
|
31
|
+
api.registerMemoryPromptSection(({ availableTools }) => {
|
|
32
|
+
const sections = [
|
|
33
|
+
"## Cognitive Memory (NEXO Brain)",
|
|
34
|
+
"",
|
|
35
|
+
"You have access to a persistent cognitive memory system. Key behaviors:",
|
|
36
|
+
"",
|
|
37
|
+
"- **Before editing code**: Call `memory_guard` to check for past errors in the files you're about to modify.",
|
|
38
|
+
"- **After resolving errors**: Call `memory_store` to prevent recurrence.",
|
|
39
|
+
"- **When user feedback is positive/negative**: Call `memory_trust` to calibrate your verification rigor.",
|
|
40
|
+
"- **When instructions conflict with past behavior**: Call `memory_dissonance` to surface the conflict.",
|
|
41
|
+
"- **At session end**: Call `memory_diary_write` to enable continuity for the next session.",
|
|
42
|
+
"",
|
|
43
|
+
"Memory decays naturally over time (Ebbinghaus curves). Frequently accessed memories get stronger.",
|
|
44
|
+
"Semantic search finds memories by meaning, not just keywords.",
|
|
45
|
+
];
|
|
46
|
+
if (guardEnabled) {
|
|
47
|
+
sections.push("", "**GUARD SYSTEM ACTIVE**: Always check `memory_guard` before code changes. It will surface known pitfalls.");
|
|
48
|
+
}
|
|
49
|
+
return sections;
|
|
50
|
+
});
|
|
51
|
+
} // end registerMemoryPromptSection guard
|
|
49
52
|
// Register all cognitive tools
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
53
|
+
const registerTool = typeof api.registerTool === "function" ? api.registerTool.bind(api) : null;
|
|
54
|
+
if (registerTool) {
|
|
55
|
+
for (const tool of COGNITIVE_TOOLS) {
|
|
56
|
+
registerTool({
|
|
57
|
+
name: tool.name,
|
|
58
|
+
label: tool.label,
|
|
59
|
+
description: tool.description,
|
|
60
|
+
parameters: tool.parameters,
|
|
61
|
+
async execute(_toolCallId, params) {
|
|
62
|
+
try {
|
|
63
|
+
const result = await bridge.callTool(tool.nexoName, params);
|
|
64
|
+
return {
|
|
65
|
+
content: [{ type: "text", text: result }],
|
|
66
|
+
details: { nexoTool: tool.nexoName },
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
71
|
+
return {
|
|
72
|
+
content: [
|
|
73
|
+
{
|
|
74
|
+
type: "text",
|
|
75
|
+
text: `Error calling ${tool.nexoName}: ${message}`,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
details: { error: true },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
}, { name: tool.name });
|
|
83
|
+
}
|
|
84
|
+
} // end registerTool guard
|
|
79
85
|
// Lifecycle: auto-recall at session start
|
|
80
|
-
|
|
86
|
+
const hasOn = typeof api.on === "function";
|
|
87
|
+
if (autoRecall && hasOn) {
|
|
81
88
|
api.on("before_agent_start", async (event) => {
|
|
82
89
|
try {
|
|
83
90
|
await bridge.start();
|
|
@@ -117,7 +124,7 @@ const plugin = {
|
|
|
117
124
|
});
|
|
118
125
|
}
|
|
119
126
|
// Lifecycle: auto-capture at session end
|
|
120
|
-
if (autoCapture) {
|
|
127
|
+
if (autoCapture && hasOn) {
|
|
121
128
|
api.on("agent_end", async (event) => {
|
|
122
129
|
try {
|
|
123
130
|
if (bridge && sessionId) {
|
|
@@ -133,47 +140,53 @@ const plugin = {
|
|
|
133
140
|
});
|
|
134
141
|
}
|
|
135
142
|
// CLI commands
|
|
136
|
-
api.registerCli
|
|
137
|
-
program
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
if (typeof api.registerCli === "function") {
|
|
144
|
+
api.registerCli(({ program }) => {
|
|
145
|
+
program
|
|
146
|
+
.command("nexo-status")
|
|
147
|
+
.description("Show NEXO Brain cognitive memory status")
|
|
148
|
+
.action(async () => {
|
|
149
|
+
try {
|
|
150
|
+
await bridge.start();
|
|
151
|
+
const stats = await bridge.callTool("nexo_cognitive_stats", {});
|
|
152
|
+
console.log(stats);
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
console.error(`Failed to get NEXO status: ${err instanceof Error ? err.message : err}`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
program
|
|
159
|
+
.command("nexo-recall")
|
|
160
|
+
.description("Search cognitive memory by meaning")
|
|
161
|
+
.argument("<query>", "Semantic search query")
|
|
162
|
+
.action(async (query) => {
|
|
163
|
+
try {
|
|
164
|
+
await bridge.start();
|
|
165
|
+
const result = await bridge.callTool("nexo_cognitive_retrieve", { query, top_k: 10 });
|
|
166
|
+
console.log(result);
|
|
167
|
+
}
|
|
168
|
+
catch (err) {
|
|
169
|
+
console.error(`Failed to recall: ${err instanceof Error ? err.message : err}`);
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}, { commands: ["nexo-status", "nexo-recall"] });
|
|
173
|
+
} // end registerCli guard
|
|
174
|
+
// Service lifecycle
|
|
175
|
+
if (typeof api.registerService === "function") {
|
|
176
|
+
api.registerService({
|
|
177
|
+
id: "memory-nexo-brain",
|
|
178
|
+
start: async () => {
|
|
156
179
|
await bridge.start();
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
180
|
+
api.logger.info("NEXO Brain cognitive engine started");
|
|
181
|
+
},
|
|
182
|
+
stop: async () => {
|
|
183
|
+
await bridge.stop();
|
|
184
|
+
api.logger.info("NEXO Brain cognitive engine stopped");
|
|
185
|
+
},
|
|
163
186
|
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
id: "memory-nexo-brain",
|
|
168
|
-
start: async () => {
|
|
169
|
-
await bridge.start();
|
|
170
|
-
api.logger.info("NEXO Brain cognitive engine started");
|
|
171
|
-
},
|
|
172
|
-
stop: async () => {
|
|
173
|
-
await bridge.stop();
|
|
174
|
-
api.logger.info("NEXO Brain cognitive engine stopped");
|
|
175
|
-
},
|
|
176
|
-
});
|
|
187
|
+
} // end registerService guard
|
|
188
|
+
if (api.logger)
|
|
189
|
+
api.logger.info("NEXO Brain plugin registered successfully");
|
|
177
190
|
},
|
|
178
191
|
};
|
|
179
192
|
export default plugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wazionapps/openclaw-memory-nexo-brain",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "OpenClaw native memory plugin powered by NEXO Brain — Atkinson-Shiffrin cognitive memory, semantic RAG, trust scoring, and metacognitive guard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|