@unblocklabs/unblock-memory 0.12.1 → 0.12.3
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 +1 -1
- package/dist/src/config.js +3 -3
- package/dist/src/diagnostics.d.ts +6 -7
- package/dist/src/diagnostics.js +1 -1
- package/dist/src/manager.d.ts +1 -2
- package/dist/src/manager.js +25 -6
- package/dist/src/memory-search.d.ts +2 -0
- package/dist/src/memory-search.js +10 -5
- package/dist/src/memory-whisperer.js +137 -150
- package/dist/src/people-learning-runtime.js +72 -10
- package/dist/src/plugin.js +1 -1
- package/dist/src/query-generator.d.ts +7 -3
- package/dist/src/query-generator.js +165 -17
- package/dist/src/response-text.d.ts +2 -0
- package/dist/src/response-text.js +182 -36
- package/dist/src/retrieval-telemetry.d.ts +2 -3
- package/dist/src/retrieval-telemetry.js +1 -1
- package/dist/src/retrieval-timing.d.ts +1 -1
- package/docs/configuration.md +6 -6
- package/docs/retrieval.md +81 -76
- package/openclaw.plugin.json +7 -7
- package/package.json +1 -1
|
@@ -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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type RetrievalTimings } from "./retrieval-timing.js";
|
|
2
2
|
type RetrievalOperation = "vector" | "memoryWhisperer" | "memorySearch";
|
|
3
3
|
type RetrievalOutcome = "ok" | "partial" | "empty" | "failed" | "cancelled" | "timed_out" | "skipped" | "degraded";
|
|
4
|
-
declare const fields: readonly ["elapsedMs", "retrievalMs", "judgeMs", "
|
|
4
|
+
declare const fields: readonly ["elapsedMs", "retrievalMs", "judgeMs", "generationMs", "setupMs", "queueWaitMs", "metadataMs", "storeSetupMs", "bm25Ms", "vectorMs", "vectorIndexCheckMs", "vectorScopeMs", "embeddingMs", "vectorScanMs", "hydrationMs", "vectorMappingMs", "vectorOtherMs", "passageMs", "candidatePrepMs", "retrievalOtherMs", "otherMs", "metadataReloads", "vectorScanAttempts", "candidates", "eligible", "results", "contextChars", "requestsSucceeded", "requestsFailed", "fallbackKeyUnavailable", "fallbackAllJudgmentsFailed"];
|
|
5
5
|
type Field = typeof fields[number];
|
|
6
6
|
export type RetrievalObservation = {
|
|
7
7
|
outcome: RetrievalOutcome;
|
|
@@ -47,11 +47,10 @@ export declare class RetrievalTelemetry {
|
|
|
47
47
|
otherMs?: number | undefined;
|
|
48
48
|
retrievalMs?: number | undefined;
|
|
49
49
|
judgeMs?: number | undefined;
|
|
50
|
+
generationMs?: number | undefined;
|
|
50
51
|
metadataReloads?: number | undefined;
|
|
51
52
|
vectorScanAttempts?: number | undefined;
|
|
52
53
|
elapsedMs?: number | undefined;
|
|
53
|
-
gateMs?: number | undefined;
|
|
54
|
-
generationMs?: number | undefined;
|
|
55
54
|
candidates?: number | undefined;
|
|
56
55
|
eligible?: number | undefined;
|
|
57
56
|
results?: number | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { timingFields } from "./retrieval-timing.js";
|
|
2
|
-
const fields = ["elapsedMs", "retrievalMs", "judgeMs", "
|
|
2
|
+
const fields = ["elapsedMs", "retrievalMs", "judgeMs", "generationMs", ...timingFields,
|
|
3
3
|
"metadataReloads", "vectorScanAttempts", "candidates", "eligible", "results", "contextChars",
|
|
4
4
|
"requestsSucceeded", "requestsFailed", "fallbackKeyUnavailable", "fallbackAllJudgmentsFailed"];
|
|
5
5
|
const recentLimit = 256;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VectorSearchTrace } from "@unblocklabs/qmd";
|
|
2
2
|
export declare const timingFields: readonly ["setupMs", "queueWaitMs", "metadataMs", "storeSetupMs", "bm25Ms", "vectorMs", "vectorIndexCheckMs", "vectorScopeMs", "embeddingMs", "vectorScanMs", "hydrationMs", "vectorMappingMs", "vectorOtherMs", "passageMs", "candidatePrepMs", "retrievalOtherMs", "otherMs"];
|
|
3
|
-
type TimingField = typeof timingFields[number] | "retrievalMs" | "judgeMs";
|
|
3
|
+
type TimingField = typeof timingFields[number] | "retrievalMs" | "judgeMs" | "generationMs";
|
|
4
4
|
export type RetrievalTimings = Partial<Record<TimingField | "metadataReloads" | "vectorScanAttempts", number>>;
|
|
5
5
|
/** Freeze in-flight duration at abort, without changing the work's cancellation behavior. */
|
|
6
6
|
export declare function startTiming(field: TimingField, timings?: RetrievalTimings, signal?: AbortSignal): () => void;
|
package/docs/configuration.md
CHANGED
|
@@ -15,7 +15,7 @@ settings; a rotated credential file is reread without a restart.
|
|
|
15
15
|
| `memory_search` | Installed/enabled memory slot; configured corpora | Local retrieval-ranked leads with degraded warning | Successful judged siblings returned with a partial warning; total judging failure or unreadable key uses local retrieval fallback |
|
|
16
16
|
| `memory_get` | Installed/enabled memory slot; configured corpora | Unchanged local indexed reads | Unchanged; its own indexing errors still matter |
|
|
17
17
|
| Skill Whisperer | `skillWhisperer.enabled`, skills corpus, host hooks | Best local vector candidate meeting `minScore` | Exclude failed candidates; successful siblings may qualify; no vector fallback |
|
|
18
|
-
| Memory Whisperer | `memoryWhisperer.enabled`, explicit approved corpora, host hooks | No hints | Exclude failed candidates;
|
|
18
|
+
| Memory Whisperer | `memoryWhisperer.enabled`, explicit approved corpora, host hooks | No hints | Exclude failed candidates; deadline failures still suppress the turn; query-API failures fall back to deterministic local queries before TypeSafe judging |
|
|
19
19
|
| Complementary hints | Enabled Memory Whisperer + `complementaryHints` | No additional judgment; base hints also require a key | Keep baseline hints unless the total deadline expires |
|
|
20
20
|
| Safety Whisperer | `safetyWhisperer.enabled`, at least one scenario, host hooks (conversation access and prompt injection) | Could not check: the turn proceeds without safety prompts (fails open) | Fails open; recorded as could-not-check, never as no match |
|
|
21
21
|
| People store/tools | `people.enabled` | Available; automatic save review needs primer/key or verified manual alternative | Storage/inspection still available |
|
|
@@ -42,7 +42,7 @@ All plugin TypeSafe features use `plugins.entries.unblock-memory.config.typesafe
|
|
|
42
42
|
|
|
43
43
|
Candidate scoring uses **one HTTP request per candidate**, with ranking done in code.
|
|
44
44
|
Related questions about the same candidate can share a request (for example, quality
|
|
45
|
-
noise and evidence). Memory Whisperer launches
|
|
45
|
+
noise and evidence). Memory Whisperer launches up to six top fused eligible candidate requests together;
|
|
46
46
|
the shared account's request/token limits still apply across simultaneous conversations
|
|
47
47
|
and nodes. There is no automatic retry in the latency-sensitive whisperers.
|
|
48
48
|
|
|
@@ -228,10 +228,10 @@ contract; these tables explain their effects.
|
|
|
228
228
|
| `memoryWhisperer.enabled` | `false` | Requires explicit approved non-skill corpora, TypeSafe key and host hooks |
|
|
229
229
|
| `memoryWhisperer.corpora` | `[]` | Explicit known corpus names; required nonempty when enabled; no `all` or skills |
|
|
230
230
|
| `memoryWhisperer.api.endpoint` | `http://192.168.1.191:18087` | Resident V2 query-model API base URL. Override with `http://127.0.0.1:18087` for a node hosting its own API (e.g. Theo). |
|
|
231
|
-
| `memoryWhisperer.api.apiKeyFile` | unset | Absolute path to a file containing the API bearer token. Missing credentials
|
|
231
|
+
| `memoryWhisperer.api.apiKeyFile` | unset | Absolute path to a file containing the API bearer token. Missing credentials, timeouts, or API failures fall back to deterministic local queries before TypeSafe judging. |
|
|
232
232
|
| `memoryWhisperer.mlx` | unset | Deprecated: old absolute `{pythonPath, modelPath}` values are accepted but ignored for upgrade compatibility. Remove after configuring `api`. |
|
|
233
|
-
| `memoryWhisperer.minUsefulness` | `0.
|
|
234
|
-
| `memoryWhisperer.maxHints` | `
|
|
233
|
+
| `memoryWhisperer.minUsefulness` | `0.5` | 0–1, minimum Noul yes-probability per candidate; explicit overrides are preserved |
|
|
234
|
+
| `memoryWhisperer.maxHints` | `3` | 1–3 |
|
|
235
235
|
| `memoryWhisperer.cooldownTurns` | `10` | 0–1,000; recently injected evidence |
|
|
236
236
|
| `memoryWhisperer.timeoutMs` | `3000` | 1–10,000 total whisper deadline, not just the provider timeout |
|
|
237
237
|
| `memoryWhisperer.complementaryHints` | `false` | Optional extra redundancy judgment; does not expand retrieval or enable the feature |
|
|
@@ -381,7 +381,7 @@ boundary, not multi-tenant authorization. Approve sources for the agent's audien
|
|
|
381
381
|
| Feature | Evidence sent when explicitly enabled/approved |
|
|
382
382
|
| --- | --- |
|
|
383
383
|
| Skill selection | Bounded visible current/recent conversation + shortlisted skill names/descriptions; not skill procedures or source-path fields |
|
|
384
|
-
| Memory hints | Same 8,192-token/24,000-byte visible conversation as training goes to the configured query API
|
|
384
|
+
| Memory hints | Same 8,192-token/24,000-byte visible conversation as training goes to the configured query API (when available); TypeSafe passage judging receives the compacted conversation (current request plus at most two prior visible messages, bounded to 1,500 characters) plus one complete excerpt (up to 1,200 characters), corpus/source path, represented-message timestamps and evaluation time per candidate, capped at the top 6 RRF-fused eligible passages from at most 10 BM25 + 10 vector candidates across the approved scope. All indexed sessions in approved corpora are eligible; `chatTypes` controls DMs. |
|
|
385
385
|
| Complementarity | Up to 4 already-qualified excerpts for pairwise redundancy checks |
|
|
386
386
|
| People primer | Person identity, agent name, approved retrieved excerpts and source/session metadata; all indexed sessions eligible if approved, not just the current chat |
|
|
387
387
|
| Dossier save/draft review | Proposed blurb, person/agent names and 1–3 exact approved indexed evidence ranges, at most 6,000 characters total; existing dossier is not evidence |
|
package/docs/retrieval.md
CHANGED
|
@@ -23,12 +23,12 @@ Example tool input (the `memory` corpus exists by default):
|
|
|
23
23
|
Results use compact JSON and carry `path`, `startLine`, `endLine`, `snippet`,
|
|
24
24
|
`corpus`, and a `score`. With `rankingMode: "typesafe_usefulness"`, this is a
|
|
25
25
|
usefulness probability rounded to hundredths; ranking and threshold filtering
|
|
26
|
-
still use full precision. With `rankingMode: "retrieval"`,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
still use full precision. With `rankingMode: "retrieval"`, passage-level
|
|
27
|
+
reciprocal rank fusion (RRF, `k = 60`, with QMD's top-rank bonuses) scores
|
|
28
|
+
across the BM25 and vector lanes are preserved without rounding and sorted
|
|
29
|
+
highest first (discovery order breaks ties); this is not a usefulness
|
|
30
|
+
probability. Dual-lane matches combine their per-lane RRF contributions while
|
|
31
|
+
rank-1 single-lane hits remain competitive before `maxResults` truncation.
|
|
32
32
|
`scoreMeaning` and `minUsefulnessApplied` identify the score contract explicitly.
|
|
33
33
|
The constant `source` and top-level `provider`
|
|
34
34
|
fields are omitted; `path` plus line numbers replace the redundant `citation`.
|
|
@@ -121,8 +121,8 @@ Both `memorySearch` and `memoryWhisperer` also report per-call stage measurement
|
|
|
121
121
|
- `passageMs`: rendering merged candidates; `candidatePrepMs`: eligibility checks and deduplication
|
|
122
122
|
before disclosure to TypeSafe. `judgeMs` covers the concurrent candidate judgments, not their sum.
|
|
123
123
|
- `vectorOtherMs` and `retrievalOtherMs` expose time outside measured child stages. `otherMs` accounts
|
|
124
|
-
for the remaining manual tool execution
|
|
125
|
-
|
|
124
|
+
for the remaining manual tool execution; Whisperer tracks individual stage timings without a
|
|
125
|
+
separate whole-run residual. Parent durations must not be added to their child durations.
|
|
126
126
|
|
|
127
127
|
Each measurement includes lifetime totals/sample counts and p50/p95 over up to 256 recent calls.
|
|
128
128
|
`slowestRecent` contains the five slowest calls **within that same window**, each with its outcome
|
|
@@ -309,8 +309,8 @@ or `memory_get`. Enable it in the plugin config with an explicit corpus allowlis
|
|
|
309
309
|
"memoryWhisperer": {
|
|
310
310
|
"enabled": true,
|
|
311
311
|
"corpora": ["knowledge"],
|
|
312
|
-
"minUsefulness": 0.
|
|
313
|
-
"maxHints":
|
|
312
|
+
"minUsefulness": 0.5,
|
|
313
|
+
"maxHints": 3,
|
|
314
314
|
"cooldownTurns": 10,
|
|
315
315
|
"timeoutMs": 3000
|
|
316
316
|
}
|
|
@@ -330,41 +330,40 @@ indexing/sync schedule.
|
|
|
330
330
|
The example is a plugin config fragment; `knowledge` must already be configured.
|
|
331
331
|
For a complete corpus example, use the [configuration profiles](configuration.md#example-profiles).
|
|
332
332
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
through BM25 and vectors respectively, retrieving ten candidates per backend across
|
|
342
|
-
the complete approved collection scope (not ten per collection). The lexical adapter
|
|
333
|
+
Memory Whisperer runs directly on user turns without a pre-retrieval recall-gate
|
|
334
|
+
classifier (the `historical-recall-v2` gate remains offline-training-only in
|
|
335
|
+
`memory-training`). Using the configured V2 query API — or deterministic local
|
|
336
|
+
`lex`/`vec` query extraction if the query API fails, times out, or has no
|
|
337
|
+
credentials — QMD searches its independent `lex` and `vec` queries through BM25
|
|
338
|
+
and vectors respectively, retrieving ten candidates per backend across the
|
|
339
|
+
complete approved collection scope (not ten per collection) and fusing them via
|
|
340
|
+
passage-level RRF (`k = 60`, with QMD top-rank bonuses). The lexical adapter
|
|
343
341
|
uses literal OR keywords; quotation marks do not enable exact-phrase matching.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
342
|
+
After deduplication and cooldown filtering, Whisperer sends at most the top **six**
|
|
343
|
+
fused candidates to TypeSafe, paired with a compact conversation context (the
|
|
344
|
+
current request plus at most the last two visible messages, bounded to 1,500
|
|
345
|
+
characters). TypeSafe evaluates one independent Noul question per candidate in
|
|
346
|
+
its own concurrent HTTP request: would a careful assistant use a specific factual
|
|
347
|
+
detail from the excerpt when answering the current request? Partial answers and
|
|
348
|
+
concrete leads count; repeated facts, topic/name matches without answer content,
|
|
349
|
+
unrelated details, and unsupported speculation do not.
|
|
352
350
|
This is the sole versioned Memory Whisperer usefulness prompt, shared by runtime
|
|
353
351
|
and offline training. Generated queries, ranks, retrieval scores, and other candidates
|
|
354
352
|
are never included in the passage judge's state.
|
|
355
|
-
`minUsefulness` defaults to `0.
|
|
353
|
+
`minUsefulness` defaults to `0.5` and
|
|
356
354
|
thresholds the probability of yes, not a calibrated guarantee of accuracy.
|
|
357
355
|
Explicit configured thresholds are preserved. Evaluate it on your own conversations.
|
|
358
356
|
|
|
359
|
-
**Privacy and budgets:**
|
|
360
|
-
|
|
357
|
+
**Privacy and budgets:** query generation prepares the visible conversation up to
|
|
358
|
+
8,192 pinned-LFM tokens and 24,000 UTF-8 bytes after serialization. The whole
|
|
361
359
|
current request and most recent whole messages are retained; an oversized current
|
|
362
|
-
request skips automatic memory before query generation or
|
|
360
|
+
request skips automatic memory before query generation or retrieval.
|
|
363
361
|
Diagnostics count `input_too_large`; completed logs report `outcome: "skipped"` and
|
|
364
|
-
`reason: "input_too_large"`, without recording the input.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
362
|
+
`reason: "input_too_large"`, without recording the input. Each TypeSafe usefulness
|
|
363
|
+
request receives the compacted conversation (at most 1,500 characters across the
|
|
364
|
+
current request and up to two prior visible messages) plus one complete
|
|
365
|
+
1,200-character excerpt, its corpus/source path, all represented message timestamps,
|
|
366
|
+
and the request's evaluation time, capped at six candidate requests per turn.
|
|
368
367
|
Dates record when source messages were said, without inferring event dates.
|
|
369
368
|
Session excerpts retain a complete turn or message when it fits,
|
|
370
369
|
otherwise the complete matched chunk. Chunks exceeding the excerpt budget are
|
|
@@ -376,9 +375,9 @@ already have compacted the available context. System messages, thinking blocks,
|
|
|
376
375
|
images, and tool-result messages are omitted;
|
|
377
376
|
anything quoted in ordinary user/assistant text can still be transmitted.
|
|
378
377
|
|
|
379
|
-
At most
|
|
380
|
-
`appendContext`, as a JSON array inside
|
|
381
|
-
block. Each entry contains
|
|
378
|
+
At most three qualifying excerpts (default `maxHints: 3`, configurable `1–3`) are
|
|
379
|
+
appended after the current user prompt via `appendContext`, as a JSON array inside
|
|
380
|
+
`<memory>` tags within one `<unblock_memory>` block. Each entry contains
|
|
382
381
|
only `source` (the QMD path), `lines` (for example, `27-30`), and `body` (the verbatim
|
|
383
382
|
excerpt). No instruction paragraph or required `memory_get` call is
|
|
384
383
|
added. This is still part of the same user message, not a separate message.
|
|
@@ -387,7 +386,10 @@ and overlapping source lines; recently injected content has a ten-user-turn cool
|
|
|
387
386
|
by default. Cooldown state is in memory and resets on session end or Gateway restart.
|
|
388
387
|
Memory and Skill Whisperer reuse their result when the host rebuilds the same run's
|
|
389
388
|
prompt, without repeating retrieval or advancing cooldown.
|
|
390
|
-
The complete hint payload is capped at 5,000 characters plus the wrapper tags
|
|
389
|
+
The complete hint payload is capped at 5,000 characters plus the wrapper tags;
|
|
390
|
+
when multiple selected hints exceed that limit after JSON escaping, Memory
|
|
391
|
+
Whisperer emits the highest-ranked complete hints that fit rather than slicing
|
|
392
|
+
excerpts or dropping everything, and only records cooldown for emitted hints.
|
|
391
393
|
|
|
392
394
|
All whisperer contributions share that appended block, in this order: `<memory>`,
|
|
393
395
|
`<skill>`, then `<people>` when People Whisperer has an eligible blurb. Empty sections
|
|
@@ -441,56 +443,59 @@ between that private worker protocol and the HTTP API below.
|
|
|
441
443
|
`POST /generate` accepts `{id, conversation: {history, currentRequest}}` and returns
|
|
442
444
|
`{response: {id, text}}`, where `text` is JSON with exactly two nonempty strings,
|
|
443
445
|
`lex` and `vec`. The request ID must match. Redirects, malformed/oversized responses,
|
|
444
|
-
missing credentials
|
|
446
|
+
missing credentials, timeouts (capped at half the whisperer deadline, up to 1.5s),
|
|
447
|
+
and HTTP failures log `generation_fallback` and fall back to deterministic local
|
|
448
|
+
`lex`/`vec` extraction rather than aborting retrieval; all fallback hits still pass
|
|
449
|
+
through TypeSafe usefulness judging.
|
|
445
450
|
Turn cancellation aborts HTTP and prevents late hints; already-running server-side
|
|
446
451
|
generation may finish independently. Gateway shutdown does not stop the shared API.
|
|
447
452
|
Old `mlx` config is accepted but ignored; remove it after migrating.
|
|
448
453
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
inputs. The old fixed `historyMessages` limit is not used by memory input preparation.
|
|
454
|
+
Query generation requests one `{"lex":"keywords","vec":"semantic query"}` object
|
|
455
|
+
using visible user/assistant text, the exact model prompt/template, greedy decoding,
|
|
456
|
+
and a 256-token output ceiling. It keeps the whole current request, drops oldest
|
|
457
|
+
whole history messages to fit the shared 8,192-token and 24,000-byte input budgets,
|
|
458
|
+
and excludes oversized/ambiguous inputs. The old fixed `historyMessages` limit is
|
|
459
|
+
not used by memory input preparation.
|
|
456
460
|
|
|
457
461
|
The `lex` query retrieves ten BM25 matches and `vec` retrieves ten vector matches
|
|
458
|
-
across the approved scope
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
across the approved scope, then fuses them with passage-level RRF (`k = 60` plus
|
|
463
|
+
QMD top-rank bonuses). After deduplication and cooldown filtering, up to the top
|
|
464
|
+
**six** fused passages proceed to the shared usefulness judge, with one HTTP request
|
|
465
|
+
per passage launched concurrently. Each request contains the compacted conversation
|
|
466
|
+
(up to 1,500 characters across the current request and at most two prior visible
|
|
467
|
+
messages) and only its own passage. Successful judgments remain eligible if another
|
|
462
468
|
request times out, fails HTTP/network delivery, or returns invalid answers. Scores
|
|
463
469
|
stay paired with their original passages; failed candidates are excluded, not scored
|
|
464
|
-
as zero. If all requests fail, nothing is injected.
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
The 1,200-character complete-excerpt limit, corpus checks, citations, cooldown and
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
Recall probability below 0.7 discards/cancels the speculative branch immediately;
|
|
473
|
-
no results are used until recall is approved. A recall error also emits no hint.
|
|
470
|
+
as zero. If all requests fail, nothing is injected. The total deadline and session
|
|
471
|
+
cancellation still apply to every result. No retries are added to the
|
|
472
|
+
latency-sensitive hook.
|
|
473
|
+
The 1,200-character complete-excerpt limit, corpus checks, citations, cooldown, and
|
|
474
|
+
three-hint/5,000-character complete-hint packing budget still apply. The judge sees
|
|
475
|
+
only the compacted conversation and passages, never generated queries or retrieval
|
|
476
|
+
scores.
|
|
477
|
+
|
|
474
478
|
Query output requires exactly the two nonempty string fields `lex` and `vec`;
|
|
475
|
-
surrounding whitespace is trimmed. Old query arrays are not accepted. Unparseable
|
|
476
|
-
unavailable v2 output
|
|
477
|
-
|
|
478
|
-
Nothing changes in manual `memory_search
|
|
479
|
-
|
|
479
|
+
surrounding whitespace is trimmed. Old query arrays are not accepted. Unparseable,
|
|
480
|
+
timed-out, or unavailable v2 output falls back to deterministic local `lex`/`vec`
|
|
481
|
+
queries for that turn and still requires TypeSafe passage judgments.
|
|
482
|
+
Nothing changes in manual `memory_search` beyond passage-level RRF scoring in
|
|
483
|
+
shared candidate discovery. The default total deadline remains three seconds;
|
|
484
|
+
measure the full path before choosing a larger explicit budget.
|
|
480
485
|
Already-running native retrieval may finish after cancellation, but cannot inject.
|
|
481
486
|
|
|
482
|
-
Diagnostics distinguish `queries_generated`, `failed`,
|
|
483
|
-
|
|
487
|
+
Diagnostics distinguish `queries_generated`, `generation_fallback`, `failed`,
|
|
488
|
+
and `judge_candidate_failed`. Gateway logs prefixed
|
|
484
489
|
`unblock-memory memory_whisperer` contain structured JSON with agent/run/session
|
|
485
490
|
IDs, candidate index, elapsed time, request timeout, and safe
|
|
486
491
|
failure codes (`timeout`, `cancelled`, `http_error`, `network_error`,
|
|
487
|
-
`invalid_response`; HTTP failures include the status).
|
|
488
|
-
identify the failed stage without dumping the exception.
|
|
489
|
-
record per run includes its outcome/reason, available stage
|
|
490
|
-
|
|
491
|
-
flag, and emitted hint count. Prompt rebuilds reuse the result without
|
|
492
|
-
logs. Logs never include queries, prompts, excerpts, credentials, provider
|
|
493
|
-
or raw exceptions; exact query text is not retained by this telemetry.
|
|
492
|
+
`invalid_response`, `credentials`, `unavailable`; HTTP failures include the status).
|
|
493
|
+
Unexpected local errors identify the failed stage without dumping the exception.
|
|
494
|
+
A single completion record per run includes its outcome/reason, available stage
|
|
495
|
+
timings, query/candidate counts, `queryFallback` flag, `requestsSucceeded`/`requestsFailed`,
|
|
496
|
+
partial-result flag, and emitted hint count. Prompt rebuilds reuse the result without
|
|
497
|
+
duplicate logs. Logs never include queries, prompts, excerpts, credentials, provider
|
|
498
|
+
bodies, or raw exceptions; exact query text is not retained by this telemetry.
|
|
494
499
|
|
|
495
500
|
## Skill Whisperer
|
|
496
501
|
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "unblock-memory",
|
|
3
3
|
"name": "Unblock Memory",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.3",
|
|
5
5
|
"description": "Indexes, retrieves, and analyzes configured workspace memory with existing QMD vectors.",
|
|
6
6
|
"kind": "memory",
|
|
7
7
|
"activation": { "onStartup": true },
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
},
|
|
92
92
|
"memoryWhisperer.enabled": {
|
|
93
93
|
"label": "Memory Whisperer",
|
|
94
|
-
"help": "Append up to
|
|
94
|
+
"help": "Append up to three TypeSafe-approved historical excerpts after the user prompt. Requires explicit corpora, TypeSafe credentials, and hook conversation access. Disabled by default."
|
|
95
95
|
},
|
|
96
96
|
"memoryWhisperer.corpora": {
|
|
97
97
|
"label": "Approved Hint Corpora",
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
"description": "Authenticated resident query-model API. Override endpoint with a loopback URL for nodes outside the Studio LAN.",
|
|
351
351
|
"properties": {
|
|
352
352
|
"endpoint": { "type": "string", "pattern": "^https?://", "default": "http://192.168.1.191:18087" },
|
|
353
|
-
"apiKeyFile": { "type": "string", "pattern": "^/", "description": "Absolute path to the API bearer token file
|
|
353
|
+
"apiKeyFile": { "type": "string", "pattern": "^/", "description": "Absolute path to the API bearer token file. When unset or unreadable, Memory Whisperer falls back to deterministic local queries." }
|
|
354
354
|
},
|
|
355
355
|
"default": { "endpoint": "http://192.168.1.191:18087" }
|
|
356
356
|
},
|
|
@@ -366,14 +366,14 @@
|
|
|
366
366
|
"complementaryHints": { "type": "boolean", "default": false, "description": "Optionally remove confidently redundant hints with up to six concurrent TypeSafe requests, one per directional pair. Uncertainty retains hints." },
|
|
367
367
|
"enabled": { "type": "boolean", "default": false },
|
|
368
368
|
"corpora": { "type": "array", "items": { "type": "string", "pattern": "\\S" }, "default": [] },
|
|
369
|
-
"minUsefulness": { "type": "number", "minimum": 0, "maximum": 1, "default": 0.
|
|
370
|
-
"maxHints": { "type": "integer", "minimum": 1, "maximum":
|
|
369
|
+
"minUsefulness": { "type": "number", "minimum": 0, "maximum": 1, "default": 0.5 },
|
|
370
|
+
"maxHints": { "type": "integer", "minimum": 1, "maximum": 3, "default": 3 },
|
|
371
371
|
"cooldownTurns": { "type": "integer", "minimum": 0, "maximum": 1000, "default": 10 },
|
|
372
372
|
"timeoutMs": { "type": "integer", "minimum": 1, "maximum": 10000, "default": 3000 }
|
|
373
373
|
},
|
|
374
374
|
"default": {
|
|
375
|
-
"enabled": false, "corpora": [], "minUsefulness": 0.
|
|
376
|
-
"maxHints":
|
|
375
|
+
"enabled": false, "corpora": [], "minUsefulness": 0.5,
|
|
376
|
+
"maxHints": 3, "cooldownTurns": 10, "timeoutMs": 3000,
|
|
377
377
|
"api": { "endpoint": "http://192.168.1.191:18087" }
|
|
378
378
|
}
|
|
379
379
|
},
|