shieldcortex 2.4.6 → 2.4.7
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.
|
@@ -7,7 +7,7 @@ metadata:
|
|
|
7
7
|
"openclaw":
|
|
8
8
|
{
|
|
9
9
|
"emoji": "🧠",
|
|
10
|
-
"events": ["command:new", "agent:bootstrap", "command"],
|
|
10
|
+
"events": ["command:new", "command:stop", "agent:bootstrap", "command"],
|
|
11
11
|
"requires": { "anyBins": ["npx"] },
|
|
12
12
|
"install": [{ "id": "community", "kind": "community", "label": "ShieldCortex" }],
|
|
13
13
|
},
|
|
@@ -25,6 +25,12 @@ Integrates [ShieldCortex](https://github.com/Drakon-Systems-Ltd/ShieldCortex) pe
|
|
|
25
25
|
2. Pattern-matches for decisions, bug fixes, learnings, architecture changes, and preferences
|
|
26
26
|
3. Saves up to 5 high-salience memories to ShieldCortex via mcporter
|
|
27
27
|
|
|
28
|
+
### On `/stop`, `/clear`, `/exit` (Session End)
|
|
29
|
+
1. Captures the current session transcript before it ends
|
|
30
|
+
2. Pattern-matches for important content (same patterns as `/new`)
|
|
31
|
+
3. Saves memories with a `session-stop` tag for tracking
|
|
32
|
+
4. **Ensures work is saved** even when explicitly ending a session
|
|
33
|
+
|
|
28
34
|
### On Session Start (Agent Bootstrap)
|
|
29
35
|
1. Calls Cortex `get_context` to retrieve relevant memories
|
|
30
36
|
2. Injects them into the agent's bootstrap context
|
|
@@ -187,6 +187,49 @@ async function onSessionEnd(event) {
|
|
|
187
187
|
console.log(`[cortex-memory] Saved ${saved}/${memories.length} memories from session`);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Handle command:stop — extract memories before session ends
|
|
192
|
+
* This fires when user explicitly calls /stop
|
|
193
|
+
*/
|
|
194
|
+
async function onSessionStop(event) {
|
|
195
|
+
const context = event.context || {};
|
|
196
|
+
const sessionEntry = context.sessionEntry || {};
|
|
197
|
+
const sessionFile = sessionEntry.sessionFile;
|
|
198
|
+
|
|
199
|
+
if (!sessionFile) {
|
|
200
|
+
console.log("[cortex-memory] No session file found for stop, skipping extraction");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const messages = await getRecentMessages(sessionFile);
|
|
205
|
+
if (messages.length === 0) {
|
|
206
|
+
console.log("[cortex-memory] No messages to extract on stop");
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const memories = extractMemories(messages);
|
|
211
|
+
if (memories.length === 0) {
|
|
212
|
+
console.log("[cortex-memory] No high-salience content found on stop");
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
let saved = 0;
|
|
217
|
+
for (const mem of memories) {
|
|
218
|
+
const result = await callCortex("remember", {
|
|
219
|
+
title: mem.title,
|
|
220
|
+
content: mem.content,
|
|
221
|
+
category: mem.category,
|
|
222
|
+
project: "openclaw",
|
|
223
|
+
scope: "global",
|
|
224
|
+
importance: "high",
|
|
225
|
+
tags: "auto-extracted,openclaw-hook,session-stop",
|
|
226
|
+
});
|
|
227
|
+
if (result) saved++;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
console.log(`[cortex-memory] Saved ${saved}/${memories.length} memories on session stop`);
|
|
231
|
+
}
|
|
232
|
+
|
|
190
233
|
/**
|
|
191
234
|
* Handle agent:bootstrap — inject past context into agent
|
|
192
235
|
*/
|
|
@@ -216,7 +259,7 @@ async function onBootstrap(event) {
|
|
|
216
259
|
* Handle command events — check for keyword triggers
|
|
217
260
|
*/
|
|
218
261
|
async function onKeywordTrigger(event) {
|
|
219
|
-
if (event.action === "new" || event.action === "stop") return;
|
|
262
|
+
if (event.action === "new" || event.action === "stop" || event.action === "clear" || event.action === "exit") return;
|
|
220
263
|
|
|
221
264
|
const context = event.context || {};
|
|
222
265
|
const sessionEntry = context.sessionEntry || {};
|
|
@@ -263,6 +306,11 @@ const cortexMemoryHandler = async (event) => {
|
|
|
263
306
|
try {
|
|
264
307
|
if (event.type === "command" && event.action === "new") {
|
|
265
308
|
await onSessionEnd(event);
|
|
309
|
+
} else if (event.type === "command" && event.action === "stop") {
|
|
310
|
+
await onSessionStop(event);
|
|
311
|
+
} else if (event.type === "command" && (event.action === "clear" || event.action === "exit")) {
|
|
312
|
+
// Also save on clear/exit - these also end the session context
|
|
313
|
+
await onSessionStop(event);
|
|
266
314
|
} else if (event.type === "agent" && event.action === "bootstrap") {
|
|
267
315
|
await onBootstrap(event);
|
|
268
316
|
} else if (event.type === "command") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shieldcortex",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.7",
|
|
4
4
|
"description": "Complete memory system + security layer for AI agents. Native OpenClaw integration. Persistent storage, semantic search, prompt injection firewall, credential protection, and audit trail. One package, full solution.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|