@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.
Files changed (123) hide show
  1. package/README.md +19 -18
  2. package/dist/src/analysis.js +1 -1
  3. package/dist/src/cluster-review.d.ts +2 -0
  4. package/dist/src/cluster-review.js +3 -3
  5. package/dist/src/config.d.ts +9 -6
  6. package/dist/src/config.js +31 -20
  7. package/dist/src/curation.d.ts +1 -1
  8. package/dist/src/decision-client.d.ts +39 -0
  9. package/dist/src/decision-client.js +74 -0
  10. package/dist/src/{typesafe.d.ts → decision-ranking.d.ts} +15 -18
  11. package/dist/src/decision-ranking.js +154 -0
  12. package/dist/src/{typesafe-review.d.ts → decision-review.d.ts} +13 -9
  13. package/dist/src/decision-review.js +192 -0
  14. package/dist/src/diagnostics.d.ts +5 -5
  15. package/dist/src/emotion-baselines.d.ts +28 -3
  16. package/dist/src/emotion-baselines.js +309 -113
  17. package/dist/src/evidence-review.d.ts +22 -8
  18. package/dist/src/evidence-review.js +4 -4
  19. package/dist/src/extraction-chunk.d.ts +3 -0
  20. package/dist/src/extraction-chunk.js +23 -5
  21. package/dist/src/extraction-model.d.ts +2 -0
  22. package/dist/src/extraction-model.js +73 -48
  23. package/dist/src/extraction-runtime.d.ts +3 -1
  24. package/dist/src/extraction-runtime.js +43 -16
  25. package/dist/src/extraction-source.d.ts +1 -1
  26. package/dist/src/extraction-source.js +19 -11
  27. package/dist/src/extraction-store.d.ts +28 -3
  28. package/dist/src/extraction-store.js +145 -23
  29. package/dist/src/extraction-worker.d.ts +1 -0
  30. package/dist/src/extraction-worker.js +246 -93
  31. package/dist/src/inside-out-runtime.js +41 -29
  32. package/dist/src/inside-out-store.d.ts +2 -2
  33. package/dist/src/inside-out-store.js +110 -69
  34. package/dist/src/inside-out.d.ts +10 -9
  35. package/dist/src/inside-out.js +190 -105
  36. package/dist/src/manager.d.ts +22 -9
  37. package/dist/src/manager.js +275 -169
  38. package/dist/src/memory-search.d.ts +4 -2
  39. package/dist/src/memory-search.js +5 -5
  40. package/dist/src/memory-whisperer.d.ts +1 -1
  41. package/dist/src/memory-whisperer.js +189 -127
  42. package/dist/src/my-turn.d.ts +1 -1
  43. package/dist/src/my-turn.js +87 -68
  44. package/dist/src/people-background.d.ts +4 -0
  45. package/dist/src/people-background.js +29 -6
  46. package/dist/src/people-dossier-review.d.ts +20 -8
  47. package/dist/src/people-dossier-review.js +11 -8
  48. package/dist/src/people-hooks.js +127 -22
  49. package/dist/src/people-learning-cron.d.ts +1 -1
  50. package/dist/src/people-learning-cron.js +106 -57
  51. package/dist/src/people-learning-inventory.d.ts +1 -0
  52. package/dist/src/people-learning-inventory.js +281 -171
  53. package/dist/src/people-learning-prompt.js +1 -1
  54. package/dist/src/people-learning-runtime.d.ts +1 -1
  55. package/dist/src/people-learning-runtime.js +423 -204
  56. package/dist/src/people-learning-store.d.ts +27 -4
  57. package/dist/src/people-learning-store.js +312 -96
  58. package/dist/src/people-primer-tool.js +8 -6
  59. package/dist/src/people-primer.d.ts +3 -1
  60. package/dist/src/people-primer.js +61 -44
  61. package/dist/src/people-store.d.ts +18 -21
  62. package/dist/src/people-store.js +186 -63
  63. package/dist/src/people-tools.js +136 -92
  64. package/dist/src/plugin.js +16 -16
  65. package/dist/src/quality-audit.d.ts +2 -0
  66. package/dist/src/quality-audit.js +8 -7
  67. package/dist/src/query-generator.d.ts +1 -1
  68. package/dist/src/query-generator.js +15 -8
  69. package/dist/src/response-audit.d.ts +1 -1
  70. package/dist/src/response-audit.js +76 -43
  71. package/dist/src/response-episodes.d.ts +1 -1
  72. package/dist/src/response-episodes.js +12 -17
  73. package/dist/src/response-judge.d.ts +151 -145
  74. package/dist/src/response-judge.js +535 -204
  75. package/dist/src/response-reviews.d.ts +29 -1
  76. package/dist/src/response-reviews.js +110 -13
  77. package/dist/src/response-runtime.js +8 -8
  78. package/dist/src/response-stages.d.ts +50 -53
  79. package/dist/src/response-stages.js +10 -4
  80. package/dist/src/response-store.d.ts +7 -6
  81. package/dist/src/response-store.js +332 -210
  82. package/dist/src/response-text.d.ts +2 -0
  83. package/dist/src/response-text.js +182 -36
  84. package/dist/src/review-tools.d.ts +8 -2
  85. package/dist/src/review-tools.js +18 -18
  86. package/dist/src/runtime.d.ts +7 -4
  87. package/dist/src/runtime.js +624 -98
  88. package/dist/src/safety-whisperer.d.ts +2 -2
  89. package/dist/src/safety-whisperer.js +88 -71
  90. package/dist/src/session-sync.d.ts +3 -1
  91. package/dist/src/session-sync.js +200 -95
  92. package/dist/src/skill-whisperer.d.ts +1 -1
  93. package/dist/src/skill-whisperer.js +52 -30
  94. package/dist/src/training-gate.d.ts +8 -21
  95. package/dist/src/training-gate.js +32 -35
  96. package/dist/src/training-judge.d.ts +9 -16
  97. package/dist/src/training-judge.js +5 -5
  98. package/dist/src/training-queries.d.ts +13 -8
  99. package/dist/src/training-queries.js +370 -228
  100. package/dist/src/training-retrieval.d.ts +14 -24
  101. package/dist/src/training-retrieval.js +182 -136
  102. package/dist/src/training-runtime.d.ts +3 -0
  103. package/dist/src/training-runtime.js +76 -18
  104. package/dist/src/training-store.d.ts +18 -3
  105. package/dist/src/training-store.js +138 -50
  106. package/dist/src/training.js +8 -11
  107. package/dist/src/whisperer-context.d.ts +14 -0
  108. package/dist/src/whisperer-context.js +22 -1
  109. package/docs/configuration.md +76 -63
  110. package/docs/extraction.md +9 -7
  111. package/docs/memory-training.md +7 -6
  112. package/docs/people-learning.md +2 -2
  113. package/docs/peoplesql.md +6 -6
  114. package/docs/response-audit.md +10 -8
  115. package/docs/retrieval.md +40 -37
  116. package/openclaw.plugin.json +40 -26
  117. package/package.json +3 -2
  118. package/skills/memory-curator/SKILL.md +1 -1
  119. package/skills/people-whisperer/SKILL.md +1 -1
  120. package/dist/src/typesafe-client.d.ts +0 -30
  121. package/dist/src/typesafe-client.js +0 -92
  122. package/dist/src/typesafe-review.js +0 -154
  123. 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]+)\)\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
- let metadata;
16
- try {
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
- let meta;
44
- try {
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(/^System: \[[^\]\r\n]+\] Slack (?:message in [^\r\n]+|DM) from ([^\r\n]+)\r?\n\r?\n/gm)];
54
- if (markers.length !== 1 || markers[0][1] !== meta.sender.name)
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
- context = rest.slice(0, marker.index).trim() || undefined;
58
- contextLimited = meta.history_truncated === true || rest.slice(0, marker.index).includes("Chat history since last reply:");
59
- text = rest.slice(marker.index + marker[0].length).trim();
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 contexts = [...text.matchAll(/\r?\n\r?\nContext: ⟦openclaw:ctx⟧\r?\n/g)];
63
- if (contexts.length) {
64
- if (contexts.length !== 1)
65
- return undefined;
66
- const context = contexts[0];
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⟧") || /^Chat history since last reply:/m.test(text))
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>>, typesafe: UnblockMemoryConfig["typesafe"], signal?: AbortSignal): Promise<{
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: "TypeSafe API key not configured";
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;
@@ -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 { resolveTypeSafeApiKey } from "./typesafe-client.js";
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, typesafe, signal) {
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(resolveTypeSafeApiKey(typesafe), combined);
21
+ const apiKey = await abortable(resolveDecisionCredential(decisionModel), combined);
22
22
  if (!apiKey)
23
- return { status: "unavailable", reason: "TypeSafe API key not configured" };
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: typesafe.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 TypeSafe.",
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.typesafe.enabled) {
41
+ if (config.decisionModel.enabled) {
42
42
  try {
43
- credential = await resolveTypeSafeApiKey(config.typesafe) ? "available" : "missing";
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.typesafe.enabled,
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.typesafe.enabled },
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. TypeSafe advisory only; does not write, authorize writes, or establish current truth. Requires evidenceReview approval for every cited corpus.",
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.typesafe.enabled)
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.typesafe, signal);
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 TypeSafe. Does not modify tasks, sources or clusters; findings apply only to sampled members.",
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.typesafe.enabled)
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.typesafe, signal);
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" });
@@ -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;