@unblocklabs/unblock-memory 0.12.2 → 0.13.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 +19 -18
- package/dist/src/analysis.js +1 -1
- package/dist/src/cluster-review.d.ts +2 -0
- package/dist/src/cluster-review.js +3 -3
- package/dist/src/config.d.ts +9 -6
- package/dist/src/config.js +31 -20
- package/dist/src/curation.d.ts +1 -1
- package/dist/src/decision-client.d.ts +39 -0
- package/dist/src/decision-client.js +74 -0
- package/dist/src/{typesafe.d.ts → decision-ranking.d.ts} +15 -18
- package/dist/src/decision-ranking.js +154 -0
- package/dist/src/{typesafe-review.d.ts → decision-review.d.ts} +13 -9
- package/dist/src/decision-review.js +192 -0
- package/dist/src/diagnostics.d.ts +5 -5
- package/dist/src/emotion-baselines.d.ts +28 -3
- package/dist/src/emotion-baselines.js +309 -113
- package/dist/src/evidence-review.d.ts +22 -8
- package/dist/src/evidence-review.js +4 -4
- package/dist/src/extraction-chunk.d.ts +3 -0
- package/dist/src/extraction-chunk.js +23 -5
- package/dist/src/extraction-model.d.ts +2 -0
- package/dist/src/extraction-model.js +73 -48
- package/dist/src/extraction-runtime.d.ts +3 -1
- package/dist/src/extraction-runtime.js +43 -16
- package/dist/src/extraction-source.d.ts +1 -1
- package/dist/src/extraction-source.js +19 -11
- package/dist/src/extraction-store.d.ts +28 -3
- package/dist/src/extraction-store.js +145 -23
- package/dist/src/extraction-worker.d.ts +1 -0
- package/dist/src/extraction-worker.js +246 -93
- package/dist/src/inside-out-runtime.js +41 -29
- package/dist/src/inside-out-store.d.ts +2 -2
- package/dist/src/inside-out-store.js +110 -69
- package/dist/src/inside-out.d.ts +10 -9
- package/dist/src/inside-out.js +190 -105
- package/dist/src/manager.d.ts +22 -9
- package/dist/src/manager.js +275 -169
- package/dist/src/memory-search.d.ts +4 -2
- package/dist/src/memory-search.js +5 -5
- package/dist/src/memory-whisperer.d.ts +1 -1
- package/dist/src/memory-whisperer.js +189 -127
- package/dist/src/my-turn.d.ts +1 -1
- package/dist/src/my-turn.js +87 -68
- package/dist/src/people-background.d.ts +4 -0
- package/dist/src/people-background.js +29 -6
- package/dist/src/people-dossier-review.d.ts +20 -8
- package/dist/src/people-dossier-review.js +11 -8
- package/dist/src/people-hooks.js +127 -22
- package/dist/src/people-learning-cron.d.ts +1 -1
- package/dist/src/people-learning-cron.js +106 -57
- package/dist/src/people-learning-inventory.d.ts +1 -0
- package/dist/src/people-learning-inventory.js +281 -171
- package/dist/src/people-learning-prompt.js +1 -1
- package/dist/src/people-learning-runtime.d.ts +1 -1
- package/dist/src/people-learning-runtime.js +423 -204
- package/dist/src/people-learning-store.d.ts +27 -4
- package/dist/src/people-learning-store.js +312 -96
- package/dist/src/people-primer-tool.js +8 -6
- package/dist/src/people-primer.d.ts +3 -1
- package/dist/src/people-primer.js +61 -44
- package/dist/src/people-store.d.ts +18 -21
- package/dist/src/people-store.js +186 -63
- package/dist/src/people-tools.js +136 -92
- package/dist/src/plugin.js +16 -16
- package/dist/src/quality-audit.d.ts +2 -0
- package/dist/src/quality-audit.js +8 -7
- package/dist/src/query-generator.d.ts +1 -1
- package/dist/src/query-generator.js +15 -8
- package/dist/src/response-audit.d.ts +1 -1
- package/dist/src/response-audit.js +76 -43
- package/dist/src/response-episodes.d.ts +1 -1
- package/dist/src/response-episodes.js +12 -17
- package/dist/src/response-judge.d.ts +151 -145
- package/dist/src/response-judge.js +535 -204
- package/dist/src/response-reviews.d.ts +29 -1
- package/dist/src/response-reviews.js +110 -13
- package/dist/src/response-runtime.js +8 -8
- package/dist/src/response-stages.d.ts +50 -53
- package/dist/src/response-stages.js +10 -4
- package/dist/src/response-store.d.ts +7 -6
- package/dist/src/response-store.js +332 -210
- package/dist/src/response-text.d.ts +2 -0
- package/dist/src/response-text.js +182 -36
- package/dist/src/review-tools.d.ts +8 -2
- package/dist/src/review-tools.js +18 -18
- package/dist/src/runtime.d.ts +7 -4
- package/dist/src/runtime.js +624 -98
- package/dist/src/safety-whisperer.d.ts +2 -2
- package/dist/src/safety-whisperer.js +88 -71
- package/dist/src/session-sync.d.ts +3 -1
- package/dist/src/session-sync.js +200 -95
- package/dist/src/skill-whisperer.d.ts +1 -1
- package/dist/src/skill-whisperer.js +52 -30
- package/dist/src/training-gate.d.ts +8 -21
- package/dist/src/training-gate.js +32 -35
- package/dist/src/training-judge.d.ts +9 -16
- package/dist/src/training-judge.js +5 -5
- package/dist/src/training-queries.d.ts +13 -8
- package/dist/src/training-queries.js +370 -228
- package/dist/src/training-retrieval.d.ts +14 -24
- package/dist/src/training-retrieval.js +182 -136
- package/dist/src/training-runtime.d.ts +3 -0
- package/dist/src/training-runtime.js +76 -18
- package/dist/src/training-store.d.ts +18 -3
- package/dist/src/training-store.js +138 -50
- package/dist/src/training.js +8 -11
- package/dist/src/whisperer-context.d.ts +14 -0
- package/dist/src/whisperer-context.js +22 -1
- package/docs/configuration.md +76 -63
- package/docs/extraction.md +9 -7
- package/docs/memory-training.md +7 -6
- package/docs/people-learning.md +2 -2
- package/docs/peoplesql.md +6 -6
- package/docs/response-audit.md +10 -8
- package/docs/retrieval.md +40 -37
- package/openclaw.plugin.json +40 -26
- package/package.json +3 -2
- package/skills/memory-curator/SKILL.md +1 -1
- package/skills/people-whisperer/SKILL.md +1 -1
- package/dist/src/typesafe-client.d.ts +0 -30
- package/dist/src/typesafe-client.js +0 -92
- package/dist/src/typesafe-review.js +0 -154
- package/dist/src/typesafe.js +0 -147
|
@@ -1,10 +1,170 @@
|
|
|
1
|
-
export const CONVERSATION_INFO = /^Conversation info: ⟦openclaw:ctx⟧\r?\n```json\r?\n([^]*?)\r?\n```\r?\n/;
|
|
2
|
-
const FROM_HEADER = /^From: [^\r\n]+ \(([^()\r\n]+)\)
|
|
1
|
+
export const CONVERSATION_INFO = /^(?:\[OpenClaw conversation info: [^\r\n]*\]\r?\n)?Conversation info: ⟦openclaw:ctx⟧\r?\n```json\r?\n([^]*?)\r?\n```\r?\n/;
|
|
2
|
+
const FROM_HEADER = /^From: [^\r\n]+ \(([^()\r\n]+)\)(?:\r?\n|$)/;
|
|
3
|
+
const SLACK_MESSAGE_LINE = /^System: \[[^\]\r\n]+\] Slack (?:message in [^\r\n]+|DM) from ([^\r\n]+)$/gm;
|
|
4
|
+
const SYSTEM_EVENT_LINE = /^System: \[[^\]\r\n]+\] [^\r\n]+$/;
|
|
5
|
+
const INBOUND_HISTORY_MARKER = /^(?:Chat history since last reply|Recent chat history)(?: \(untrusted, for context\))?:/m;
|
|
6
|
+
const INBOUND_CTX_HEADER = /^[A-Za-z][A-Za-z0-9 _()/-]*: ⟦openclaw:ctx⟧$/;
|
|
7
|
+
const INBOUND_DELIVERY_HINT = /^Delivery: (?:to send a message, use the `message` tool\.|Final assistant text is not automatically delivered in this run\.[^\r\n]*|No visible reply is delivered automatically in this run[^\r\n]*)$/;
|
|
8
|
+
const LEGACY_REQUESTER_PROFILE_HINT = 'requester_profile is the verified linked requester. For "assign to me", use sessions assign_owner with ownerType="human" and ownerId=requester_profile.id, if available.';
|
|
9
|
+
const ACTIVE_GOAL_LINE = /^Active goal: [^\r\n]+$/;
|
|
10
|
+
const CURRENT_MESSAGE_MARKER = "[Current message - respond to this]";
|
|
11
|
+
function readLine(text, start) {
|
|
12
|
+
if (start >= text.length)
|
|
13
|
+
return undefined;
|
|
14
|
+
const lf = text.indexOf("\n", start);
|
|
15
|
+
const end = lf < 0 ? text.length : lf;
|
|
16
|
+
const next = lf < 0 ? text.length : lf + 1;
|
|
17
|
+
return { start, end, next, trimmed: text.slice(start, end).trim() };
|
|
18
|
+
}
|
|
19
|
+
function parseConversationHeader(rawJson) {
|
|
20
|
+
let meta;
|
|
21
|
+
try {
|
|
22
|
+
meta = JSON.parse(rawJson);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
if (!meta || typeof meta !== "object" || Array.isArray(meta))
|
|
28
|
+
return undefined;
|
|
29
|
+
return {
|
|
30
|
+
senderId: typeof meta.sender?.id === "string" ? meta.sender.id : undefined,
|
|
31
|
+
senderName: typeof meta.sender?.name === "string" ? meta.sender.name : undefined,
|
|
32
|
+
historyTruncated: meta.history_truncated === true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function stripChannelContextSuffix(text) {
|
|
36
|
+
const contexts = [...text.matchAll(/\r?\n\r?\nContext: ⟦openclaw:ctx⟧\r?\n/g)];
|
|
37
|
+
if (!contexts.length)
|
|
38
|
+
return { text, stripped: false };
|
|
39
|
+
if (contexts.length !== 1)
|
|
40
|
+
return undefined;
|
|
41
|
+
const context = contexts[0];
|
|
42
|
+
const suffix = text.slice(context.index + context[0].length);
|
|
43
|
+
if (!suffix.trim() || suffix.includes("⟦openclaw:ctx⟧") || INBOUND_HISTORY_MARKER.test(suffix))
|
|
44
|
+
return undefined;
|
|
45
|
+
return { text: text.slice(0, context.index).trim(), stripped: true };
|
|
46
|
+
}
|
|
47
|
+
/** Advance past one validated Slack message line, any adjacent non-message System lines, and the required blank separator line. */
|
|
48
|
+
function slackMarkerBodyStart(rest, markerEnd) {
|
|
49
|
+
let pos = markerEnd;
|
|
50
|
+
if (rest[pos] === "\r")
|
|
51
|
+
pos++;
|
|
52
|
+
if (rest[pos] !== "\n")
|
|
53
|
+
return undefined;
|
|
54
|
+
pos++;
|
|
55
|
+
while (pos < rest.length) {
|
|
56
|
+
const line = readLine(rest, pos);
|
|
57
|
+
if (!line)
|
|
58
|
+
return undefined;
|
|
59
|
+
if (line.trimmed === "")
|
|
60
|
+
return line.next;
|
|
61
|
+
if (!SYSTEM_EVENT_LINE.test(line.trimmed))
|
|
62
|
+
return undefined;
|
|
63
|
+
pos = line.next;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
3
67
|
/** Infer legacy transport sender metadata only to unwrap visible conversation text. */
|
|
4
68
|
export function conversationUserText(raw, sender) {
|
|
5
69
|
const parsed = conversationEnvelope(raw, sender);
|
|
6
70
|
return parsed && { text: parsed.text, contextLimited: parsed.contextLimited };
|
|
7
71
|
}
|
|
72
|
+
/** Unwrap human text for recall query generation, including non-Slack OpenClaw inbound envelopes. */
|
|
73
|
+
export function queryUserText(raw, sender) {
|
|
74
|
+
const standard = conversationUserText(raw, sender);
|
|
75
|
+
if (standard)
|
|
76
|
+
return standard.text;
|
|
77
|
+
const trimmed = raw.trim();
|
|
78
|
+
const header = CONVERSATION_INFO.exec(trimmed);
|
|
79
|
+
if (!header)
|
|
80
|
+
return undefined;
|
|
81
|
+
const meta = parseConversationHeader(header[1]);
|
|
82
|
+
if (!meta || (typeof sender === "string" && meta.senderId !== sender))
|
|
83
|
+
return undefined;
|
|
84
|
+
const rest = trimmed.slice(header[0].length);
|
|
85
|
+
// Slack envelopes must pass strict speaker-marker validation in userEnvelope.
|
|
86
|
+
if ([...rest.matchAll(SLACK_MESSAGE_LINE)].length > 0)
|
|
87
|
+
return undefined;
|
|
88
|
+
let pos = 0;
|
|
89
|
+
while (pos < rest.length) {
|
|
90
|
+
let line = readLine(rest, pos);
|
|
91
|
+
while (line && line.trimmed === "") {
|
|
92
|
+
pos = line.next;
|
|
93
|
+
line = readLine(rest, pos);
|
|
94
|
+
}
|
|
95
|
+
if (!line)
|
|
96
|
+
break;
|
|
97
|
+
if (line.trimmed === "Conversation info: ⟦openclaw:ctx⟧")
|
|
98
|
+
return undefined;
|
|
99
|
+
if (INBOUND_CTX_HEADER.test(line.trimmed) && line.trimmed !== "Context: ⟦openclaw:ctx⟧") {
|
|
100
|
+
const label = line.trimmed;
|
|
101
|
+
pos = line.next;
|
|
102
|
+
const open = readLine(rest, pos);
|
|
103
|
+
if (open?.trimmed === "```json") {
|
|
104
|
+
pos = open.next;
|
|
105
|
+
const jsonStart = pos;
|
|
106
|
+
let close = readLine(rest, pos);
|
|
107
|
+
while (close && close.trimmed !== "```") {
|
|
108
|
+
pos = close.next;
|
|
109
|
+
close = readLine(rest, pos);
|
|
110
|
+
}
|
|
111
|
+
if (!close)
|
|
112
|
+
return undefined;
|
|
113
|
+
if (label === "Sender: ⟦openclaw:ctx⟧" && meta.senderId !== undefined) {
|
|
114
|
+
let senderMeta;
|
|
115
|
+
try {
|
|
116
|
+
senderMeta = JSON.parse(rest.slice(jsonStart, close.start));
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
if (typeof senderMeta?.id === "string" && senderMeta.id !== meta.senderId)
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
pos = close.next;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
let content = open;
|
|
128
|
+
while (content && content.trimmed !== "") {
|
|
129
|
+
pos = content.next;
|
|
130
|
+
content = readLine(rest, pos);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
if (line.trimmed === "Context:") {
|
|
136
|
+
const open = readLine(rest, line.next);
|
|
137
|
+
if (open?.trimmed === "<active_memory_plugin>") {
|
|
138
|
+
let scan = readLine(rest, open.next);
|
|
139
|
+
while (scan && scan.trimmed !== "</active_memory_plugin>")
|
|
140
|
+
scan = readLine(rest, scan.next);
|
|
141
|
+
if (!scan)
|
|
142
|
+
return undefined;
|
|
143
|
+
pos = scan.next;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (INBOUND_DELIVERY_HINT.test(line.trimmed) || line.trimmed === CURRENT_MESSAGE_MARKER ||
|
|
148
|
+
line.trimmed === LEGACY_REQUESTER_PROFILE_HINT || ACTIVE_GOAL_LINE.test(line.trimmed)) {
|
|
149
|
+
pos = line.next;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
const stripped = stripChannelContextSuffix(rest.slice(pos).trim());
|
|
155
|
+
if (!stripped)
|
|
156
|
+
return undefined;
|
|
157
|
+
let body = stripped.text;
|
|
158
|
+
const from = FROM_HEADER.exec(body);
|
|
159
|
+
if (from) {
|
|
160
|
+
if (meta.senderId === undefined || from[1] !== meta.senderId)
|
|
161
|
+
return undefined;
|
|
162
|
+
body = body.slice(from[0].length).trim();
|
|
163
|
+
}
|
|
164
|
+
if (!body || body.includes("⟦openclaw:ctx⟧") || INBOUND_HISTORY_MARKER.test(body))
|
|
165
|
+
return undefined;
|
|
166
|
+
return body;
|
|
167
|
+
}
|
|
8
168
|
/** Like conversationUserText, plus the untrusted inbound context (thread starter, reply target,
|
|
9
169
|
* chat history) that a recognized envelope carries before the current message. */
|
|
10
170
|
export function conversationEnvelope(raw, sender) {
|
|
@@ -12,17 +172,10 @@ export function conversationEnvelope(raw, sender) {
|
|
|
12
172
|
if (senderId === undefined) {
|
|
13
173
|
const header = CONVERSATION_INFO.exec(raw.trim());
|
|
14
174
|
if (header) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
metadata = JSON.parse(header[1]);
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
175
|
+
const meta = parseConversationHeader(header[1]);
|
|
176
|
+
if (!meta || meta.senderId === undefined)
|
|
20
177
|
return;
|
|
21
|
-
|
|
22
|
-
if (metadata && typeof metadata === "object" && "sender" in metadata && metadata.sender &&
|
|
23
|
-
typeof metadata.sender === "object" && "id" in metadata.sender && typeof metadata.sender.id === "string") {
|
|
24
|
-
senderId = metadata.sender.id;
|
|
25
|
-
}
|
|
178
|
+
senderId = meta.senderId;
|
|
26
179
|
}
|
|
27
180
|
senderId ??= FROM_HEADER.exec(raw.trim())?.[1];
|
|
28
181
|
}
|
|
@@ -40,36 +193,29 @@ function userEnvelope(input, senderId) {
|
|
|
40
193
|
let context;
|
|
41
194
|
const header = CONVERSATION_INFO.exec(text);
|
|
42
195
|
if (header) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
meta = JSON.parse(header[1]);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
if (!meta || meta.sender?.id !== senderId || typeof meta.sender.name !== "string")
|
|
196
|
+
const meta = parseConversationHeader(header[1]);
|
|
197
|
+
if (!meta || meta.senderId !== senderId || meta.senderName === undefined)
|
|
51
198
|
return undefined;
|
|
52
199
|
const rest = text.slice(header[0].length);
|
|
53
|
-
const markers = [...rest.matchAll(
|
|
54
|
-
if (markers.length !== 1 || markers[0][1] !== meta.
|
|
200
|
+
const markers = [...rest.matchAll(SLACK_MESSAGE_LINE)];
|
|
201
|
+
if (markers.length !== 1 || markers[0][1] !== meta.senderName)
|
|
55
202
|
return undefined;
|
|
56
203
|
const marker = markers[0];
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
204
|
+
const bodyStart = slackMarkerBodyStart(rest, marker.index + marker[0].length);
|
|
205
|
+
if (bodyStart === undefined)
|
|
206
|
+
return undefined;
|
|
207
|
+
const prefix = rest.slice(0, marker.index);
|
|
208
|
+
context = prefix.trim() || undefined;
|
|
209
|
+
contextLimited = meta.historyTruncated || INBOUND_HISTORY_MARKER.test(prefix);
|
|
210
|
+
text = rest.slice(bodyStart).trim();
|
|
60
211
|
// OpenClaw appends channel metadata after the current Slack message. Only
|
|
61
212
|
// recognize its exact boundary inside an already validated envelope.
|
|
62
|
-
const
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const suffix = text.slice(context.index + context[0].length);
|
|
68
|
-
if (!suffix.trim() || suffix.includes("⟦openclaw:ctx⟧") || /^Chat history since last reply:/m.test(suffix))
|
|
69
|
-
return undefined;
|
|
70
|
-
text = text.slice(0, context.index).trim();
|
|
213
|
+
const stripped = stripChannelContextSuffix(text);
|
|
214
|
+
if (!stripped)
|
|
215
|
+
return undefined;
|
|
216
|
+
text = stripped.text;
|
|
217
|
+
if (stripped.stripped)
|
|
71
218
|
contextLimited = true;
|
|
72
|
-
}
|
|
73
219
|
}
|
|
74
220
|
else {
|
|
75
221
|
const from = FROM_HEADER.exec(text);
|
|
@@ -80,7 +226,7 @@ function userEnvelope(input, senderId) {
|
|
|
80
226
|
}
|
|
81
227
|
}
|
|
82
228
|
// Unrecognized/nested envelopes cannot safely supply the current human text.
|
|
83
|
-
if (!text || text.includes("⟦openclaw:ctx⟧") ||
|
|
229
|
+
if (!text || text.includes("⟦openclaw:ctx⟧") || INBOUND_HISTORY_MARKER.test(text))
|
|
84
230
|
return undefined;
|
|
85
231
|
return { text, contextLimited, ...(context ? { context } : {}) };
|
|
86
232
|
}
|
|
@@ -4,11 +4,13 @@ import type { QmdMemoryRuntime } from "./runtime.js";
|
|
|
4
4
|
import type { WhispererDiagnostics } from "./diagnostics.js";
|
|
5
5
|
import { getContext } from "./tool-context.js";
|
|
6
6
|
/** Bound initialization as well as inference, without cancelling shared managers. */
|
|
7
|
-
export declare function reviewRequestContext(runtime: QmdMemoryRuntime, active: NonNullable<ReturnType<typeof getContext>>,
|
|
7
|
+
export declare function reviewRequestContext(runtime: QmdMemoryRuntime, active: NonNullable<ReturnType<typeof getContext>>, decisionModel: UnblockMemoryConfig["decisionModel"], signal?: AbortSignal): Promise<{
|
|
8
8
|
readonly status: "unavailable";
|
|
9
|
-
readonly reason: "
|
|
9
|
+
readonly reason: "Decision model API key not configured";
|
|
10
10
|
readonly manager?: undefined;
|
|
11
11
|
readonly apiKey?: undefined;
|
|
12
|
+
readonly endpoint?: undefined;
|
|
13
|
+
readonly model?: undefined;
|
|
12
14
|
readonly signal?: undefined;
|
|
13
15
|
readonly timeoutMs?: undefined;
|
|
14
16
|
} | {
|
|
@@ -16,12 +18,16 @@ export declare function reviewRequestContext(runtime: QmdMemoryRuntime, active:
|
|
|
16
18
|
readonly reason: "Memory manager unavailable";
|
|
17
19
|
readonly manager?: undefined;
|
|
18
20
|
readonly apiKey?: undefined;
|
|
21
|
+
readonly endpoint?: undefined;
|
|
22
|
+
readonly model?: undefined;
|
|
19
23
|
readonly signal?: undefined;
|
|
20
24
|
readonly timeoutMs?: undefined;
|
|
21
25
|
} | {
|
|
22
26
|
readonly status: "ready";
|
|
23
27
|
readonly manager: import("./manager.js").QmdMemoryManager;
|
|
24
28
|
readonly apiKey: string;
|
|
29
|
+
readonly endpoint: string;
|
|
30
|
+
readonly model: string;
|
|
25
31
|
readonly signal: AbortSignal;
|
|
26
32
|
readonly timeoutMs: number;
|
|
27
33
|
reason?: undefined;
|
package/dist/src/review-tools.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Type } from "typebox";
|
|
|
2
2
|
import { Value } from "typebox/value";
|
|
3
3
|
import { jsonResult } from "openclaw/plugin-sdk/agent-runtime";
|
|
4
4
|
import { getContext } from "./tool-context.js";
|
|
5
|
-
import {
|
|
5
|
+
import { resolveDecisionCredential } from "./decision-client.js";
|
|
6
6
|
import { safetyStatus } from "./safety-whisperer.js";
|
|
7
7
|
import { abortable } from "./abortable.js";
|
|
8
8
|
const claimParameters = Type.Object({
|
|
@@ -15,16 +15,16 @@ const claimParameters = Type.Object({
|
|
|
15
15
|
const clusterParameters = Type.Object({ clusterId: Type.String({ pattern: "^[0-9a-f]{10}$" }) }, { additionalProperties: false });
|
|
16
16
|
const noParameters = Type.Object({}, { additionalProperties: false });
|
|
17
17
|
/** Bound initialization as well as inference, without cancelling shared managers. */
|
|
18
|
-
export async function reviewRequestContext(runtime, active,
|
|
18
|
+
export async function reviewRequestContext(runtime, active, decisionModel, signal) {
|
|
19
19
|
const deadline = AbortSignal.timeout(30_000);
|
|
20
20
|
const combined = signal ? AbortSignal.any([signal, deadline]) : deadline;
|
|
21
|
-
const apiKey = await abortable(
|
|
21
|
+
const apiKey = await abortable(resolveDecisionCredential(decisionModel), combined);
|
|
22
22
|
if (!apiKey)
|
|
23
|
-
return { status: "unavailable", reason: "
|
|
23
|
+
return { status: "unavailable", reason: "Decision model API key not configured" };
|
|
24
24
|
const { manager } = await abortable(runtime.getMemorySearchManager(active), combined);
|
|
25
25
|
if (!manager)
|
|
26
26
|
return { status: "unavailable", reason: "Memory manager unavailable" };
|
|
27
|
-
return { status: "ready", manager, apiKey, signal: combined, timeoutMs:
|
|
27
|
+
return { status: "ready", manager, apiKey, endpoint: decisionModel.endpoint, model: decisionModel.model, signal: combined, timeoutMs: decisionModel.timeoutMs };
|
|
28
28
|
}
|
|
29
29
|
export function registerReviewTools(api, runtime, config, diagnostics) {
|
|
30
30
|
api.registerTool(ctx => {
|
|
@@ -33,23 +33,23 @@ export function registerReviewTools(api, runtime, config, diagnostics) {
|
|
|
33
33
|
return null;
|
|
34
34
|
return {
|
|
35
35
|
name: "memory_diagnostics", label: "Memory Diagnostics",
|
|
36
|
-
description: "Read content-free manual-search and whisperer telemetry, configuration state, projection version and index readiness. Does not call
|
|
36
|
+
description: "Read content-free manual-search and whisperer telemetry, configuration state, projection version and index readiness. Does not call decision model.",
|
|
37
37
|
parameters: noParameters,
|
|
38
38
|
async execute(_id, params) {
|
|
39
39
|
Value.Parse(noParameters, params);
|
|
40
40
|
let credential = "disabled";
|
|
41
|
-
if (config.
|
|
41
|
+
if (config.decisionModel.enabled) {
|
|
42
42
|
try {
|
|
43
|
-
credential = await
|
|
43
|
+
credential = await resolveDecisionCredential(config.decisionModel) ? "available" : "missing";
|
|
44
44
|
}
|
|
45
45
|
catch {
|
|
46
46
|
credential = "unreadable";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
const result = { status: "ok", credential,
|
|
50
|
-
enabled: { skill: config.skillWhisperer.enabled, memory: config.memoryWhisperer.enabled && config.
|
|
50
|
+
enabled: { skill: config.skillWhisperer.enabled, memory: config.memoryWhisperer.enabled && config.decisionModel.enabled,
|
|
51
51
|
complementaryHints: config.memoryWhisperer.complementaryHints, qualityAudit: config.qualityAudit.enabled, evidenceReview: config.evidenceReview.enabled,
|
|
52
|
-
safety: config.safetyWhisperer.enabled, myTurn: config.myTurn.enabled && config.
|
|
52
|
+
safety: config.safetyWhisperer.enabled, myTurn: config.myTurn.enabled && config.decisionModel.enabled },
|
|
53
53
|
safety: safetyStatus(api.config, config),
|
|
54
54
|
whisperers: diagnostics.snapshot(active.agentId) };
|
|
55
55
|
try {
|
|
@@ -68,18 +68,18 @@ export function registerReviewTools(api, runtime, config, diagnostics) {
|
|
|
68
68
|
return null;
|
|
69
69
|
return {
|
|
70
70
|
name: "memory_review_claim", label: "Review Memory Claim",
|
|
71
|
-
description: "Before a knowledge or dossier write, check one proposed atomic claim against cited indexed source lines.
|
|
71
|
+
description: "Before a knowledge or dossier write, check one proposed atomic claim against cited indexed source lines. decision model advisory only; does not write, authorize writes, or establish current truth. Requires evidenceReview approval for every cited corpus.",
|
|
72
72
|
parameters: claimParameters,
|
|
73
73
|
async execute(_id, params, signal) {
|
|
74
74
|
const parsed = Value.Parse(claimParameters, params);
|
|
75
|
-
if (!config.evidenceReview.enabled || !config.
|
|
75
|
+
if (!config.evidenceReview.enabled || !config.decisionModel.enabled)
|
|
76
76
|
return jsonResult({ status: "disabled" });
|
|
77
77
|
try {
|
|
78
|
-
const context = await reviewRequestContext(runtime, active, config.
|
|
78
|
+
const context = await reviewRequestContext(runtime, active, config.decisionModel, signal);
|
|
79
79
|
if (context.status !== "ready")
|
|
80
80
|
return jsonResult(context);
|
|
81
81
|
return jsonResult(await context.manager.reviewClaim({ ...parsed, corpora: config.evidenceReview.corpora,
|
|
82
|
-
apiKey: context.apiKey, timeoutMs: context.timeoutMs, signal: context.signal }));
|
|
82
|
+
apiKey: context.apiKey, endpoint: context.endpoint, model: context.model, timeoutMs: context.timeoutMs, signal: context.signal }));
|
|
83
83
|
}
|
|
84
84
|
catch {
|
|
85
85
|
return jsonResult({ status: "unavailable", needsReview: true, reason: "Claim review failed or was cancelled; no claim verified" });
|
|
@@ -93,18 +93,18 @@ export function registerReviewTools(api, runtime, config, diagnostics) {
|
|
|
93
93
|
return null;
|
|
94
94
|
return {
|
|
95
95
|
name: "memory_review_cluster", label: "Review Cluster Ingestion",
|
|
96
|
-
description: "Inspect up to six complete center/edge cluster members for recurring ingestion defects. Uses qualityAudit approved corpora and
|
|
96
|
+
description: "Inspect up to six complete center/edge cluster members for recurring ingestion defects. Uses qualityAudit approved corpora and decision model. Does not modify tasks, sources or clusters; findings apply only to sampled members.",
|
|
97
97
|
parameters: clusterParameters,
|
|
98
98
|
async execute(_id, params, signal) {
|
|
99
99
|
const parsed = Value.Parse(clusterParameters, params);
|
|
100
|
-
if (!config.qualityAudit.enabled || !config.
|
|
100
|
+
if (!config.qualityAudit.enabled || !config.decisionModel.enabled)
|
|
101
101
|
return jsonResult({ status: "disabled" });
|
|
102
102
|
try {
|
|
103
|
-
const context = await reviewRequestContext(runtime, active, config.
|
|
103
|
+
const context = await reviewRequestContext(runtime, active, config.decisionModel, signal);
|
|
104
104
|
if (context.status !== "ready")
|
|
105
105
|
return jsonResult(context);
|
|
106
106
|
return jsonResult(await context.manager.reviewCluster({ ...parsed, corpora: config.qualityAudit.corpora,
|
|
107
|
-
apiKey: context.apiKey, timeoutMs: context.timeoutMs, signal: context.signal }));
|
|
107
|
+
apiKey: context.apiKey, endpoint: context.endpoint, model: context.model, timeoutMs: context.timeoutMs, signal: context.signal }));
|
|
108
108
|
}
|
|
109
109
|
catch {
|
|
110
110
|
return jsonResult({ status: "unavailable", reason: "Cluster review failed or was cancelled; no cluster judgment made" });
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ type StoredRunningSessionSync = Extract<StoredSessionSyncStatus, {
|
|
|
38
38
|
}> & {
|
|
39
39
|
pid: number;
|
|
40
40
|
};
|
|
41
|
-
export declare function recoverInterruptedSessionSync(directory: string, statusPath: string, stale: StoredRunningSessionSync): Promise<SessionSyncStatus>;
|
|
41
|
+
export declare function recoverInterruptedSessionSync(directory: string, statusPath: string, stale: StoredRunningSessionSync, onError?: (error: unknown) => void): Promise<SessionSyncStatus>;
|
|
42
42
|
export declare class QmdMemoryRuntime implements MemoryPluginRuntimeContract {
|
|
43
43
|
#private;
|
|
44
44
|
startSessionSyncSchedule(cfg: OpenClawConfig, onError: (error: unknown) => void): void;
|
|
@@ -48,16 +48,17 @@ export declare class QmdMemoryRuntime implements MemoryPluginRuntimeContract {
|
|
|
48
48
|
keepEmbeddingModelWarm?: boolean;
|
|
49
49
|
stateRoot?: string;
|
|
50
50
|
extraction?: ExtractionConfig;
|
|
51
|
+
onError?: (error: unknown) => void;
|
|
51
52
|
});
|
|
52
53
|
getMemorySearchManager(params: {
|
|
53
54
|
cfg: OpenClawConfig;
|
|
54
55
|
agentId: string;
|
|
55
56
|
}): Promise<{
|
|
56
|
-
manager: QmdMemoryManager;
|
|
57
|
-
error?: undefined;
|
|
58
|
-
} | {
|
|
59
57
|
manager: null;
|
|
60
58
|
error: string;
|
|
59
|
+
} | {
|
|
60
|
+
manager: QmdMemoryManager;
|
|
61
|
+
error?: undefined;
|
|
61
62
|
}>;
|
|
62
63
|
resolveMemoryBackendConfig(): {
|
|
63
64
|
backend: "builtin";
|
|
@@ -68,10 +69,12 @@ export declare class QmdMemoryRuntime implements MemoryPluginRuntimeContract {
|
|
|
68
69
|
agentId: string;
|
|
69
70
|
}, force?: boolean): Promise<SessionSyncStartResult>;
|
|
70
71
|
sessionSyncStatus(agentId: string): Promise<SessionSyncStatus>;
|
|
72
|
+
prepareReload(change: Parameters<NonNullable<MemoryPluginRuntimeContract["prepareReload"]>>[0]): ReturnType<NonNullable<MemoryPluginRuntimeContract["prepareReload"]>>;
|
|
71
73
|
closeMemorySearchManager(params: {
|
|
72
74
|
agentId: string;
|
|
73
75
|
}): Promise<void>;
|
|
74
76
|
closeAllMemorySearchManagers(): Promise<void>;
|
|
77
|
+
close(): Promise<void>;
|
|
75
78
|
searchSkills(params: {
|
|
76
79
|
cfg: OpenClawConfig;
|
|
77
80
|
agentId: string;
|