openclaw-memory-atmem 2.0.0 → 2.1.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/README.md +2 -2
- package/dist/index.js +92 -46
- package/dist/src/rpc-client.js +1 -1
- package/openclaw.plugin.json +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,11 +5,11 @@ This npm package is the host bridge for AtMem. It is not a standalone memory eng
|
|
|
5
5
|
Use the Python-owned installer:
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
python -m pip install atmem==2.
|
|
8
|
+
python -m pip install atmem==2.1.0
|
|
9
9
|
atmem openclaw install
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
The installer pins `openclaw-memory-atmem@2.
|
|
12
|
+
The installer pins `openclaw-memory-atmem@2.1.0`, binds the exact `atmem` executable, copies existing OpenClaw memory, configures shadow mode, restarts the gateway and verifies the loaded plugin. Direct npm installation cannot perform or prove those steps.
|
|
13
13
|
|
|
14
14
|
In shadow mode the bridge observes native-memory changes without injecting AtMem context. In active mode it exposes compatible memory search/get tools, model-semantic capture, bounded recall and native-path protection. `atmem control restore` restores the saved OpenClaw configuration and native memory.
|
|
15
15
|
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,19 @@ function parseConfig(raw) {
|
|
|
43
43
|
const cfg = (raw ?? {});
|
|
44
44
|
const dbPath = expandHome(String(cfg.dbPath ?? "~/.atmem/memories.db"));
|
|
45
45
|
const subject = String(cfg.subject ?? "default");
|
|
46
|
+
const stringMap = (value) => value && typeof value === "object" && !Array.isArray(value)
|
|
47
|
+
? Object.fromEntries(Object.entries(value)
|
|
48
|
+
.filter(([, item]) => typeof item === "string" && item.trim())
|
|
49
|
+
.map(([key, item]) => [key, String(item)]))
|
|
50
|
+
: {};
|
|
51
|
+
const agentSubjects = stringMap(cfg.agentSubjects);
|
|
52
|
+
const agentWorkspaces = Object.fromEntries(Object.entries(stringMap(cfg.agentWorkspaces)).map(([key, value]) => [key, expandHome(value)]));
|
|
53
|
+
const nativeWorkspace = expandHome(String(cfg.nativeWorkspace ?? ""));
|
|
54
|
+
const nativeWorkspaces = [...new Set([
|
|
55
|
+
...(Array.isArray(cfg.nativeWorkspaces) ? cfg.nativeWorkspaces.map((item) => expandHome(String(item))) : []),
|
|
56
|
+
...Object.values(agentWorkspaces),
|
|
57
|
+
nativeWorkspace,
|
|
58
|
+
].filter(Boolean))];
|
|
46
59
|
const controlPlane = {
|
|
47
60
|
enabled: cfg.controlPlane?.enabled === true,
|
|
48
61
|
statePath: expandHome(String(cfg.controlPlane?.statePath ?? "~/.atmem/control-plane.json")),
|
|
@@ -57,8 +70,12 @@ function parseConfig(raw) {
|
|
|
57
70
|
: ["mcp", "--db", dbPath, "--subject", subject],
|
|
58
71
|
dbPath,
|
|
59
72
|
subject,
|
|
73
|
+
defaultAgentId: String(cfg.defaultAgentId ?? "main"),
|
|
74
|
+
agentSubjects,
|
|
75
|
+
agentWorkspaces,
|
|
60
76
|
takeoverActive: cfg.takeoverActive === true,
|
|
61
|
-
nativeWorkspace
|
|
77
|
+
nativeWorkspace,
|
|
78
|
+
nativeWorkspaces,
|
|
62
79
|
recall: {
|
|
63
80
|
enabled: cfg.recall?.enabled !== false,
|
|
64
81
|
maxRecords: Number(cfg.recall?.maxRecords ?? 3),
|
|
@@ -312,7 +329,31 @@ function register(api) {
|
|
|
312
329
|
const inboundAttachments = new Map();
|
|
313
330
|
const inboundAttachmentGeneration = new Map();
|
|
314
331
|
let nextAttachmentGeneration = 0;
|
|
315
|
-
const
|
|
332
|
+
const agentIdFor = (ctx) => {
|
|
333
|
+
if (ctx.agentId?.trim())
|
|
334
|
+
return ctx.agentId.trim();
|
|
335
|
+
const session = ctx.sessionKey ?? ctx.sessionId ?? "";
|
|
336
|
+
const match = /^agent:([^:]+)(?::|$)/.exec(session);
|
|
337
|
+
return match?.[1] ?? cfg.defaultAgentId;
|
|
338
|
+
};
|
|
339
|
+
const subjectFor = (ctx) => {
|
|
340
|
+
const agentId = agentIdFor(ctx);
|
|
341
|
+
if (Object.keys(cfg.agentSubjects).length) {
|
|
342
|
+
const mapped = cfg.agentSubjects[agentId];
|
|
343
|
+
if (!mapped)
|
|
344
|
+
throw new Error(`unmapped OpenClaw persistent agent: ${agentId}`);
|
|
345
|
+
return mapped;
|
|
346
|
+
}
|
|
347
|
+
return cfg.subject;
|
|
348
|
+
};
|
|
349
|
+
const scopedKey = (value, ctx) => `${agentIdFor(ctx)}:${value}`;
|
|
350
|
+
const contextIds = (ctx) => [...new Set([ctx.runId, ctx.sessionKey, ctx.sessionId].filter((value) => Boolean(value)).map((value) => scopedKey(value, ctx)))];
|
|
351
|
+
const callFor = (ctx, name, args, timeoutMs = cfg.recall.timeoutMs) => {
|
|
352
|
+
const scoped = cfg.controlPlane.enabled && !Object.keys(cfg.agentSubjects).length
|
|
353
|
+
? args
|
|
354
|
+
: { ...args, subject_id: subjectFor(ctx) };
|
|
355
|
+
return client.callTool(name, scoped, timeoutMs);
|
|
356
|
+
};
|
|
316
357
|
const digestText = (value) => createHash("sha256").update(value, "utf8").digest("hex");
|
|
317
358
|
const stableValue = (value) => {
|
|
318
359
|
if (Array.isArray(value))
|
|
@@ -346,6 +387,8 @@ function register(api) {
|
|
|
346
387
|
await blackboxClient.callTool("control_record_blackbox_event", {
|
|
347
388
|
event_type: eventType,
|
|
348
389
|
run_id: flightRunId(eventRunId, ctx),
|
|
390
|
+
agent_id: agentIdFor(ctx),
|
|
391
|
+
subject_id: Object.keys(cfg.agentSubjects).length ? subjectFor(ctx) : undefined,
|
|
349
392
|
session_id: ctx.sessionId ?? ctx.sessionKey,
|
|
350
393
|
tool_call_id: toolCallId,
|
|
351
394
|
turn_id: correlation.turnId ?? flightRunId(eventRunId, ctx),
|
|
@@ -382,7 +425,7 @@ function register(api) {
|
|
|
382
425
|
const ids = contextIds(ctx);
|
|
383
426
|
if (!ids.length)
|
|
384
427
|
return;
|
|
385
|
-
await
|
|
428
|
+
await callFor(ctx, "memory_stage_user_message", {
|
|
386
429
|
message: text.trim(),
|
|
387
430
|
source_aliases: ids,
|
|
388
431
|
run_id: ctx.runId,
|
|
@@ -499,7 +542,7 @@ function register(api) {
|
|
|
499
542
|
const visibleText = responses.map(String).join("");
|
|
500
543
|
const assistantVisibleTextSha256 = digestText(visibleText);
|
|
501
544
|
const modelOutputBundleSha256 = digestJson(responses);
|
|
502
|
-
const sessionKey = ctx.sessionKey ?? ctx.sessionId ?? event.sessionId ?? "default-session";
|
|
545
|
+
const sessionKey = scopedKey(ctx.sessionKey ?? ctx.sessionId ?? event.sessionId ?? "default-session", ctx);
|
|
503
546
|
const pending = pendingPrompts.get(sessionKey);
|
|
504
547
|
if (pending) {
|
|
505
548
|
pendingPrompts.set(sessionKey, {
|
|
@@ -570,7 +613,7 @@ function register(api) {
|
|
|
570
613
|
}, { commands: ["atmem"] });
|
|
571
614
|
// L3 persona cache: rebuilt on TTL expiry and invalidated when capture
|
|
572
615
|
// writes new memory, so the snapshot never lags a correction.
|
|
573
|
-
|
|
616
|
+
const personaCaches = new Map();
|
|
574
617
|
const sweep = () => {
|
|
575
618
|
const now = Date.now();
|
|
576
619
|
for (const [key, value] of pendingPrompts) {
|
|
@@ -582,40 +625,43 @@ function register(api) {
|
|
|
582
625
|
inboundAttachments.delete(key);
|
|
583
626
|
}
|
|
584
627
|
};
|
|
585
|
-
async function personaBlock(sessionKey) {
|
|
628
|
+
async function personaBlock(sessionKey, ctx) {
|
|
586
629
|
if (!cfg.persona.enabled)
|
|
587
630
|
return { block: "", recordIds: [] };
|
|
588
631
|
const now = Date.now();
|
|
632
|
+
const subject = subjectFor(ctx);
|
|
633
|
+
const personaCache = personaCaches.get(subject);
|
|
589
634
|
if (personaCache && now - personaCache.ts < cfg.persona.ttlSeconds * 1000) {
|
|
590
635
|
return personaCache;
|
|
591
636
|
}
|
|
592
|
-
const result = (await
|
|
637
|
+
const result = (await callFor(ctx, "memory_persona", {
|
|
593
638
|
session_id: sessionKey,
|
|
594
639
|
max_chars: cfg.persona.maxChars,
|
|
595
640
|
reference_mode: cfg.cacheAware.enabled && cfg.cacheAware.compactReferences
|
|
596
641
|
? "compact"
|
|
597
642
|
: "full",
|
|
598
643
|
}, cfg.recall.timeoutMs));
|
|
599
|
-
|
|
644
|
+
const refreshed = {
|
|
600
645
|
block: result?.block ?? "",
|
|
601
646
|
recordIds: result?.record_ids ?? [],
|
|
602
647
|
contextEventId: result?.context_event_id,
|
|
603
648
|
ts: now,
|
|
604
649
|
};
|
|
605
|
-
|
|
650
|
+
personaCaches.set(subject, refreshed);
|
|
651
|
+
return refreshed;
|
|
606
652
|
}
|
|
607
653
|
// ---- auto-recall: persona + bounded, audited recall injection ---------
|
|
608
654
|
api.on("before_prompt_build", async (event, ctx) => {
|
|
609
655
|
const userText = event.prompt;
|
|
610
656
|
if (!userText)
|
|
611
657
|
return;
|
|
612
|
-
const sessionKey = ctx.sessionKey ?? ctx.sessionId ?? "default-session";
|
|
658
|
+
const sessionKey = scopedKey(ctx.sessionKey ?? ctx.sessionId ?? "default-session", ctx);
|
|
613
659
|
const takeoverGuidance = cfg.takeoverActive ? TAKEOVER_GUIDANCE : "";
|
|
614
660
|
pendingPrompts.set(sessionKey, { text: userText, ts: Date.now() });
|
|
615
661
|
sweep();
|
|
616
662
|
if (cfg.controlPlane.enabled) {
|
|
617
663
|
try {
|
|
618
|
-
const prepared = (await
|
|
664
|
+
const prepared = (await callFor(ctx, "control_prepare", { query: userText, session_id: sessionKey, agent_id: agentIdFor(ctx) }, cfg.recall.timeoutMs));
|
|
619
665
|
pendingPrompts.set(sessionKey, {
|
|
620
666
|
text: userText,
|
|
621
667
|
ts: Date.now(),
|
|
@@ -687,7 +733,7 @@ function register(api) {
|
|
|
687
733
|
let recall = "";
|
|
688
734
|
let recallFailed = false;
|
|
689
735
|
try {
|
|
690
|
-
const personaResult = await personaBlock(sessionKey);
|
|
736
|
+
const personaResult = await personaBlock(sessionKey, ctx);
|
|
691
737
|
persona = personaResult.block;
|
|
692
738
|
personaRecordIds = personaResult.recordIds;
|
|
693
739
|
personaContextEventId = personaResult.contextEventId;
|
|
@@ -698,7 +744,7 @@ function register(api) {
|
|
|
698
744
|
}
|
|
699
745
|
try {
|
|
700
746
|
if (cfg.recall.enabled) {
|
|
701
|
-
const result = (await
|
|
747
|
+
const result = (await callFor(ctx, "memory_recall_block", {
|
|
702
748
|
query: userText,
|
|
703
749
|
session_id: sessionKey,
|
|
704
750
|
max_records: cfg.recall.maxRecords,
|
|
@@ -803,7 +849,7 @@ function register(api) {
|
|
|
803
849
|
? event.derivedPaths.map((value) => digestText(String(value)))
|
|
804
850
|
: [],
|
|
805
851
|
}, event.toolCallId);
|
|
806
|
-
if (!cfg.takeoverActive || !touchesNativeMemory(event,
|
|
852
|
+
if (!cfg.takeoverActive || !cfg.nativeWorkspaces.some((workspace) => touchesNativeMemory(event, workspace)))
|
|
807
853
|
return;
|
|
808
854
|
const reason = "AtMem takeover blocked access to OpenClaw's frozen native memory " +
|
|
809
855
|
"(MEMORY.md or memory/*). Use memory_remember for durable user facts, " +
|
|
@@ -831,20 +877,20 @@ function register(api) {
|
|
|
831
877
|
});
|
|
832
878
|
// ---- auto-capture: user turn through the pipeline, assistant as digest -
|
|
833
879
|
api.on("agent_end", async (event, ctx) => {
|
|
834
|
-
const sessionKey = ctx.sessionKey ?? ctx.sessionId ?? "default-session";
|
|
880
|
+
const sessionKey = scopedKey(ctx.sessionKey ?? ctx.sessionId ?? "default-session", ctx);
|
|
835
881
|
const cached = pendingPrompts.get(sessionKey);
|
|
836
882
|
pendingPrompts.delete(sessionKey);
|
|
837
883
|
const userText = cached?.text?.replace(INJECT_RE, "").trim();
|
|
838
884
|
try {
|
|
839
885
|
if (cfg.takeoverActive) {
|
|
840
|
-
await
|
|
886
|
+
await callFor(ctx, "memory_clear_user_message", { source_aliases: contextIds(ctx) }, cfg.recall.timeoutMs);
|
|
841
887
|
}
|
|
842
888
|
if (cfg.controlPlane.enabled) {
|
|
843
889
|
if (cached?.exposureId) {
|
|
844
|
-
await
|
|
890
|
+
await callFor(ctx, "control_exposure_shown", { exposure_id: cached.exposureId }, cfg.recall.timeoutMs);
|
|
845
891
|
}
|
|
846
892
|
if (event.success !== false) {
|
|
847
|
-
await
|
|
893
|
+
await callFor(ctx, "control_sync_openclaw_memory", {}, cfg.recall.timeoutMs);
|
|
848
894
|
}
|
|
849
895
|
return;
|
|
850
896
|
}
|
|
@@ -857,7 +903,7 @@ function register(api) {
|
|
|
857
903
|
const responseText = messageText(message.content);
|
|
858
904
|
if (responseText) {
|
|
859
905
|
const assistantVisibleTextSha256 = cached.assistantVisibleTextSha256 ?? digestText(responseText);
|
|
860
|
-
await
|
|
906
|
+
await callFor(ctx, "memory_log_action", {
|
|
861
907
|
action_type: "agent.response_after_memory",
|
|
862
908
|
payload: {
|
|
863
909
|
response_sha256: assistantVisibleTextSha256,
|
|
@@ -882,12 +928,12 @@ function register(api) {
|
|
|
882
928
|
!cfg.takeoverActive &&
|
|
883
929
|
event.success !== false &&
|
|
884
930
|
userText) {
|
|
885
|
-
await
|
|
931
|
+
await callFor(ctx, "memory_capture", {
|
|
886
932
|
role: "user",
|
|
887
933
|
content: userText,
|
|
888
934
|
session_id: sessionKey,
|
|
889
935
|
});
|
|
890
|
-
|
|
936
|
+
personaCaches.delete(subjectFor(ctx)); // new memory may change the persona
|
|
891
937
|
}
|
|
892
938
|
if (cfg.capture.enabled &&
|
|
893
939
|
!cfg.takeoverActive &&
|
|
@@ -899,7 +945,7 @@ function register(api) {
|
|
|
899
945
|
if (message?.role === "assistant") {
|
|
900
946
|
const text = messageText(message.content);
|
|
901
947
|
if (text) {
|
|
902
|
-
await
|
|
948
|
+
await callFor(ctx, "memory_capture", {
|
|
903
949
|
role: "assistant",
|
|
904
950
|
content: text,
|
|
905
951
|
session_id: sessionKey,
|
|
@@ -1005,9 +1051,9 @@ function register(api) {
|
|
|
1005
1051
|
additionalProperties: false,
|
|
1006
1052
|
},
|
|
1007
1053
|
async execute(toolCallId, params) {
|
|
1008
|
-
const
|
|
1009
|
-
const
|
|
1010
|
-
|
|
1054
|
+
const rawSessionKey = toolCtx.sessionKey ?? toolCtx.sessionId;
|
|
1055
|
+
const sessionKey = rawSessionKey ? scopedKey(rawSessionKey, toolCtx) : undefined;
|
|
1056
|
+
const sourceAliases = contextIds(toolCtx);
|
|
1011
1057
|
if (!sessionKey || !sourceAliases.length) {
|
|
1012
1058
|
throw new Error("no current authenticated user message is available; memory was not stored");
|
|
1013
1059
|
}
|
|
@@ -1019,7 +1065,7 @@ function register(api) {
|
|
|
1019
1065
|
.filter(Boolean)
|
|
1020
1066
|
.join(":") ??
|
|
1021
1067
|
"openclaw-agent";
|
|
1022
|
-
const result = (await
|
|
1068
|
+
const result = (await callFor(toolCtx, "memory_remember", {
|
|
1023
1069
|
source_aliases: sourceAliases,
|
|
1024
1070
|
interpreted_fact: fact,
|
|
1025
1071
|
interpreted_fact_key: params.factKey,
|
|
@@ -1032,7 +1078,7 @@ function register(api) {
|
|
|
1032
1078
|
const duplicateId = result.duplicate_ids?.[0];
|
|
1033
1079
|
const stored = Boolean(record || duplicateId);
|
|
1034
1080
|
if (stored) {
|
|
1035
|
-
|
|
1081
|
+
personaCaches.delete(subjectFor(toolCtx));
|
|
1036
1082
|
}
|
|
1037
1083
|
return {
|
|
1038
1084
|
content: [{
|
|
@@ -1055,7 +1101,7 @@ function register(api) {
|
|
|
1055
1101
|
// is disabled. Existing agent prompts and workflows can keep using the
|
|
1056
1102
|
// same tool names; only the governed storage/retrieval implementation
|
|
1057
1103
|
// changes underneath them.
|
|
1058
|
-
api.registerTool({
|
|
1104
|
+
api.registerTool((toolCtx) => ({
|
|
1059
1105
|
name: "memory_search",
|
|
1060
1106
|
label: "Memory Search",
|
|
1061
1107
|
description: "Search governed AtMem long-term memory. Compatible with OpenClaw's " +
|
|
@@ -1092,7 +1138,7 @@ function register(api) {
|
|
|
1092
1138
|
}
|
|
1093
1139
|
const sessionId = `openclaw-memory-search:${toolCallId}`;
|
|
1094
1140
|
const maxResults = Math.min(Math.max(Number(params.maxResults) || 6, 1), 20);
|
|
1095
|
-
const records = (await
|
|
1141
|
+
const records = (await callFor(toolCtx, "memory_recall", {
|
|
1096
1142
|
query: String(params.query ?? ""),
|
|
1097
1143
|
session_id: sessionId,
|
|
1098
1144
|
limit: maxResults,
|
|
@@ -1128,8 +1174,8 @@ function register(api) {
|
|
|
1128
1174
|
details: { count: results.length, corpus, sessionId },
|
|
1129
1175
|
};
|
|
1130
1176
|
},
|
|
1131
|
-
}, { name: "memory_search" });
|
|
1132
|
-
api.registerTool({
|
|
1177
|
+
}), { name: "memory_search" });
|
|
1178
|
+
api.registerTool((toolCtx) => ({
|
|
1133
1179
|
name: "memory_get",
|
|
1134
1180
|
label: "Memory Get",
|
|
1135
1181
|
description: "Read one exact governed AtMem record returned by memory_search. " +
|
|
@@ -1150,7 +1196,7 @@ function register(api) {
|
|
|
1150
1196
|
const recordId = recordIdFromPath(lookup);
|
|
1151
1197
|
if (!recordId) {
|
|
1152
1198
|
const sessionId = `openclaw-memory-get:${toolCallId}`;
|
|
1153
|
-
const sourceResult = (await
|
|
1199
|
+
const sourceResult = (await callFor(toolCtx, "memory_get_source", {
|
|
1154
1200
|
path: lookup,
|
|
1155
1201
|
session_id: sessionId,
|
|
1156
1202
|
}));
|
|
@@ -1188,7 +1234,7 @@ function register(api) {
|
|
|
1188
1234
|
};
|
|
1189
1235
|
}
|
|
1190
1236
|
const sessionId = `openclaw-memory-get:${toolCallId}`;
|
|
1191
|
-
const result = (await
|
|
1237
|
+
const result = (await callFor(toolCtx, "memory_get_record", {
|
|
1192
1238
|
record_id: recordId,
|
|
1193
1239
|
session_id: sessionId,
|
|
1194
1240
|
}));
|
|
@@ -1211,8 +1257,8 @@ function register(api) {
|
|
|
1211
1257
|
details: { found: Boolean(result?.record), sessionId },
|
|
1212
1258
|
};
|
|
1213
1259
|
},
|
|
1214
|
-
}, { name: "memory_get" });
|
|
1215
|
-
api.registerTool({
|
|
1260
|
+
}), { name: "memory_get" });
|
|
1261
|
+
api.registerTool((toolCtx) => ({
|
|
1216
1262
|
name: "atmem_search",
|
|
1217
1263
|
label: "Memory Search (atmem)",
|
|
1218
1264
|
description: "Search the user's long-term auditable memory. Use when you need " +
|
|
@@ -1228,7 +1274,7 @@ function register(api) {
|
|
|
1228
1274
|
},
|
|
1229
1275
|
async execute(toolCallId, params) {
|
|
1230
1276
|
const sessionId = `openclaw-tool:${toolCallId}`;
|
|
1231
|
-
const records = (await
|
|
1277
|
+
const records = (await callFor(toolCtx, "memory_recall", {
|
|
1232
1278
|
query: String(params.query ?? ""),
|
|
1233
1279
|
session_id: sessionId,
|
|
1234
1280
|
limit: Math.min(Math.max(Number(params.limit) || 5, 1), 20),
|
|
@@ -1241,8 +1287,8 @@ function register(api) {
|
|
|
1241
1287
|
details: { count: records.length, sessionId },
|
|
1242
1288
|
};
|
|
1243
1289
|
},
|
|
1244
|
-
}, { name: "atmem_search" });
|
|
1245
|
-
api.registerTool({
|
|
1290
|
+
}), { name: "atmem_search" });
|
|
1291
|
+
api.registerTool((toolCtx) => ({
|
|
1246
1292
|
name: "atmem_forget",
|
|
1247
1293
|
label: "Memory Forget (atmem)",
|
|
1248
1294
|
description: "Delete the user's memories matching their request — only call when " +
|
|
@@ -1261,13 +1307,13 @@ function register(api) {
|
|
|
1261
1307
|
},
|
|
1262
1308
|
async execute(toolCallId, params) {
|
|
1263
1309
|
const sessionId = `openclaw-tool:${toolCallId}`;
|
|
1264
|
-
const result = (await
|
|
1310
|
+
const result = (await callFor(toolCtx, "memory_forget", {
|
|
1265
1311
|
utterance: String(params.utterance ?? ""),
|
|
1266
1312
|
session_id: sessionId,
|
|
1267
1313
|
turn_id: toolCallId,
|
|
1268
1314
|
}));
|
|
1269
1315
|
if (result.deleted)
|
|
1270
|
-
|
|
1316
|
+
personaCaches.delete(subjectFor(toolCtx));
|
|
1271
1317
|
const text = result.deleted
|
|
1272
1318
|
? `Deleted ${result.record_ids.length} memorie(s). Receipt: ${JSON.stringify(result.receipt)}`
|
|
1273
1319
|
: "No matching memories found to delete.";
|
|
@@ -1276,7 +1322,7 @@ function register(api) {
|
|
|
1276
1322
|
details: { deleted: result.deleted, sessionId },
|
|
1277
1323
|
};
|
|
1278
1324
|
},
|
|
1279
|
-
}, { name: "atmem_forget" });
|
|
1325
|
+
}), { name: "atmem_forget" });
|
|
1280
1326
|
api.registerTool((toolCtx) => ({
|
|
1281
1327
|
name: "atmem_observe",
|
|
1282
1328
|
label: "Media Observation (atmem)",
|
|
@@ -1392,7 +1438,7 @@ function register(api) {
|
|
|
1392
1438
|
if (suppliedSegment[key] !== undefined)
|
|
1393
1439
|
segment[key] = suppliedSegment[key];
|
|
1394
1440
|
}
|
|
1395
|
-
const result = (await
|
|
1441
|
+
const result = (await callFor(toolCtx, "memory_observe", {
|
|
1396
1442
|
text: String(params.text ?? ""),
|
|
1397
1443
|
modality: requestedModality,
|
|
1398
1444
|
media_sha256: mediaSha256,
|
|
@@ -1426,7 +1472,7 @@ function register(api) {
|
|
|
1426
1472
|
};
|
|
1427
1473
|
},
|
|
1428
1474
|
}), { name: "atmem_observe" });
|
|
1429
|
-
api.registerTool({
|
|
1475
|
+
api.registerTool((toolCtx) => ({
|
|
1430
1476
|
name: "atmem_forget_artifact",
|
|
1431
1477
|
label: "Forget Media Artifact (atmem)",
|
|
1432
1478
|
description: "Only when the user explicitly requests deletion, purge all AtMem " +
|
|
@@ -1448,14 +1494,14 @@ function register(api) {
|
|
|
1448
1494
|
},
|
|
1449
1495
|
async execute(toolCallId, params) {
|
|
1450
1496
|
const sessionId = `openclaw-tool:${toolCallId}`;
|
|
1451
|
-
const result = (await
|
|
1497
|
+
const result = (await callFor(toolCtx, "memory_forget_artifact", {
|
|
1452
1498
|
media_sha256: String(params.media_sha256 ?? ""),
|
|
1453
1499
|
artifact_id: params.artifact_id,
|
|
1454
1500
|
session_id: sessionId,
|
|
1455
1501
|
turn_id: toolCallId,
|
|
1456
1502
|
}));
|
|
1457
1503
|
if (result.deleted)
|
|
1458
|
-
|
|
1504
|
+
personaCaches.delete(subjectFor(toolCtx));
|
|
1459
1505
|
const text = result.deleted
|
|
1460
1506
|
? `Purged ${result.record_ids.length} derived memorie(s). Receipt: ${JSON.stringify(result.receipt)}`
|
|
1461
1507
|
: "No active AtMem artifact matched that exact digest.";
|
|
@@ -1464,7 +1510,7 @@ function register(api) {
|
|
|
1464
1510
|
details: { deleted: result.deleted, sessionId },
|
|
1465
1511
|
};
|
|
1466
1512
|
},
|
|
1467
|
-
}, { name: "atmem_forget_artifact" });
|
|
1513
|
+
}), { name: "atmem_forget_artifact" });
|
|
1468
1514
|
}
|
|
1469
1515
|
api.logger.info(`${TAG} registered (db=${cfg.dbPath}, subject=${cfg.subject}, ` +
|
|
1470
1516
|
`recall=${cfg.recall.enabled}, capture=${cfg.capture.enabled}, ` +
|
package/dist/src/rpc-client.js
CHANGED
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "memory-atmem",
|
|
3
3
|
"name": "Memory (atmem)",
|
|
4
4
|
"description": "OpenClaw bridge installed and managed by the AtMem memory control plane.",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.1.0",
|
|
6
6
|
"commandAliases": ["memory-atmem"],
|
|
7
7
|
"activation": {
|
|
8
8
|
"onStartup": true
|
|
@@ -42,6 +42,21 @@
|
|
|
42
42
|
"default": "default",
|
|
43
43
|
"description": "Subject id used for all memory operations (single-user assistant)"
|
|
44
44
|
},
|
|
45
|
+
"defaultAgentId": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"default": "main",
|
|
48
|
+
"description": "Persistent OpenClaw agent used when a legacy hook does not expose an agent id. Managed by AtMem."
|
|
49
|
+
},
|
|
50
|
+
"agentSubjects": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"additionalProperties": { "type": "string" },
|
|
53
|
+
"description": "Persistent-agent to governed-memory-subject map. Agents sharing an exact workspace intentionally share a subject."
|
|
54
|
+
},
|
|
55
|
+
"agentWorkspaces": {
|
|
56
|
+
"type": "object",
|
|
57
|
+
"additionalProperties": { "type": "string" },
|
|
58
|
+
"description": "Persistent-agent to canonical workspace map. Managed by AtMem."
|
|
59
|
+
},
|
|
45
60
|
"takeoverActive": {
|
|
46
61
|
"type": "boolean",
|
|
47
62
|
"default": false,
|
|
@@ -51,6 +66,11 @@
|
|
|
51
66
|
"type": "string",
|
|
52
67
|
"description": "Absolute OpenClaw workspace path protected during verified takeover. Set by `atmem control activate`; do not configure manually."
|
|
53
68
|
},
|
|
69
|
+
"nativeWorkspaces": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": { "type": "string" },
|
|
72
|
+
"description": "All OpenClaw workspaces protected during takeover, including separate and nested persistent-agent workspaces."
|
|
73
|
+
},
|
|
54
74
|
"recall": {
|
|
55
75
|
"type": "object",
|
|
56
76
|
"description": "Auto-recall injection before each prompt",
|