@newbase-clawchat/openclaw-clawchat 2026.5.12-21 → 2026.5.12-22
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/dist/src/clawchat-memory.js +8 -0
- package/dist/src/runtime.js +11 -1
- package/dist/src/tools.js +3 -1
- package/package.json +1 -1
- package/src/clawchat-memory.ts +9 -0
- package/src/runtime.test.ts +9 -2
- package/src/runtime.ts +15 -1
- package/src/tools.ts +3 -1
|
@@ -248,6 +248,14 @@ export async function readClawChatMemoryFile(root, target) {
|
|
|
248
248
|
raw: file.raw,
|
|
249
249
|
};
|
|
250
250
|
}
|
|
251
|
+
export async function deleteClawChatMemoryFile(root, target) {
|
|
252
|
+
const targetPath = await ensureClawChatMemoryTargetSafe(root, target);
|
|
253
|
+
await fs.unlink(targetPath).catch((error) => {
|
|
254
|
+
if (error.code !== "ENOENT") {
|
|
255
|
+
throw error;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
251
259
|
export async function writeClawChatMemoryBody(root, target, mode, content) {
|
|
252
260
|
if (mode !== "append" && mode !== "replace") {
|
|
253
261
|
throw new Error("Invalid clawchat memory write mode");
|
package/dist/src/runtime.js
CHANGED
|
@@ -18,6 +18,7 @@ import { getClawChatGroupPrompt, getClawChatUserPrompt } from "./plugin-prompts.
|
|
|
18
18
|
import { loadClawChatPromptMetadata, renderClawChatProfilePrompt, resolveSenderRelation, } from "./profile-prompt.js";
|
|
19
19
|
import { refreshGroupProfile, syncFirstSeenClawChatProfiles } from "./profile-sync.js";
|
|
20
20
|
import { pullGroupMetadata, pullOwnerMetadata } from "./clawchat-metadata.js";
|
|
21
|
+
import { deleteClawChatMemoryFile } from "./clawchat-memory.js";
|
|
21
22
|
import { clearClawChatPromptInjectionForSession, stageClawChatPromptInjection, } from "./prompt-injection.js";
|
|
22
23
|
import { createGroupMessageCoalescer } from "./group-message-coalescer.js";
|
|
23
24
|
const { setRuntime: setOpenclawClawlingRuntime, getRuntime: getOpenclawClawlingRuntime } = createPluginRuntimeStore("openclaw-clawchat runtime not initialized");
|
|
@@ -151,7 +152,8 @@ function isConversationNotFoundError(err) {
|
|
|
151
152
|
if (!(err instanceof ClawlingApiError))
|
|
152
153
|
return false;
|
|
153
154
|
return err.meta?.status === 404 || err.meta?.status === 410 ||
|
|
154
|
-
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401
|
|
155
|
+
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401 ||
|
|
156
|
+
err.message.toLowerCase().includes("conversation not found");
|
|
155
157
|
}
|
|
156
158
|
function metadataVersionFromEnvelope(env) {
|
|
157
159
|
const payload = asRecord(env.payload);
|
|
@@ -345,6 +347,14 @@ export async function startOpenclawClawlingGateway(params) {
|
|
|
345
347
|
}
|
|
346
348
|
catch (err) {
|
|
347
349
|
if (isConversationNotFoundError(err)) {
|
|
350
|
+
if (options.memoryRoot) {
|
|
351
|
+
await deleteClawChatMemoryFile(options.memoryRoot, {
|
|
352
|
+
targetType: "group",
|
|
353
|
+
targetId: conversationId,
|
|
354
|
+
}).catch((deleteError) => {
|
|
355
|
+
log?.error?.(`[${accountId}] openclaw-clawchat group metadata file delete failed conversation=${conversationId}: ${deleteError instanceof Error ? deleteError.message : String(deleteError)}`);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
348
358
|
if (store?.deleteConversationCache) {
|
|
349
359
|
recordConnection("conversation cache delete", () => store.deleteConversationCache?.({
|
|
350
360
|
platform: "openclaw",
|
package/dist/src/tools.js
CHANGED
|
@@ -109,7 +109,9 @@ function upsertConversationDetailsCache(store, accountId, conversation) {
|
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
function isConversationNotFound(err) {
|
|
112
|
-
return err.meta?.status === 404 || err.meta?.
|
|
112
|
+
return err.meta?.status === 404 || err.meta?.status === 410 ||
|
|
113
|
+
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401 ||
|
|
114
|
+
err.message.toLowerCase().includes("conversation not found");
|
|
113
115
|
}
|
|
114
116
|
export function registerOpenclawClawlingTools(api, options = {}) {
|
|
115
117
|
if (!api.config) {
|
package/package.json
CHANGED
package/src/clawchat-memory.ts
CHANGED
|
@@ -297,6 +297,15 @@ export async function readClawChatMemoryFile(root: string, target: ClawChatMemor
|
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
export async function deleteClawChatMemoryFile(root: string, target: ClawChatMemoryTarget): Promise<void> {
|
|
301
|
+
const targetPath = await ensureClawChatMemoryTargetSafe(root, target);
|
|
302
|
+
await fs.unlink(targetPath).catch((error) => {
|
|
303
|
+
if ((error as NodeJS.ErrnoException).code !== "ENOENT") {
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
|
|
300
309
|
export async function writeClawChatMemoryBody(
|
|
301
310
|
root: string,
|
|
302
311
|
target: ClawChatMemoryTarget,
|
package/src/runtime.test.ts
CHANGED
|
@@ -1258,7 +1258,12 @@ describe("openclaw-clawchat runtime helpers", () => {
|
|
|
1258
1258
|
});
|
|
1259
1259
|
|
|
1260
1260
|
it("refreshes metadata invalidations without a version and deletes scoped cache on not found", async () => {
|
|
1261
|
-
const
|
|
1261
|
+
const memoryRoot = tempMemoryRoot();
|
|
1262
|
+
const runtime = buildNoDispatchRuntime(vi.fn().mockResolvedValue(undefined), memoryRoot);
|
|
1263
|
+
await writeClawChatMetadata(memoryRoot, { targetType: "group", targetId: "group-missing" }, {
|
|
1264
|
+
id: "group-missing",
|
|
1265
|
+
title: "Stale",
|
|
1266
|
+
});
|
|
1262
1267
|
const fetchMock = vi.spyOn(globalThis, "fetch").mockImplementation(async (input) => {
|
|
1263
1268
|
const url = String(input);
|
|
1264
1269
|
if (url.endsWith("/v1/conversations/group-no-version")) {
|
|
@@ -1268,7 +1273,7 @@ describe("openclaw-clawchat runtime helpers", () => {
|
|
|
1268
1273
|
return jsonEnvelope({ code: 0, msg: "ok", data: { id: "user-owner", nickname: "Owner" } });
|
|
1269
1274
|
}
|
|
1270
1275
|
if (url.endsWith("/v1/conversations/group-missing")) {
|
|
1271
|
-
return jsonEnvelope({ code:
|
|
1276
|
+
return jsonEnvelope({ code: 4001, msg: "conversation not found", data: {} });
|
|
1272
1277
|
}
|
|
1273
1278
|
return jsonEnvelope({ code: 0, msg: "ok", data: { agent: { id: "agt-1" } } });
|
|
1274
1279
|
});
|
|
@@ -1330,6 +1335,8 @@ describe("openclaw-clawchat runtime helpers", () => {
|
|
|
1330
1335
|
accountId: "default",
|
|
1331
1336
|
conversationId: "group-missing",
|
|
1332
1337
|
});
|
|
1338
|
+
await expect(readClawChatMemoryFile(memoryRoot, { targetType: "group", targetId: "group-missing" }))
|
|
1339
|
+
.resolves.toMatchObject({ exists: false });
|
|
1333
1340
|
|
|
1334
1341
|
abortController.abort();
|
|
1335
1342
|
await run;
|
package/src/runtime.ts
CHANGED
|
@@ -46,6 +46,7 @@ import {
|
|
|
46
46
|
} from "./profile-prompt.ts";
|
|
47
47
|
import { refreshGroupProfile, syncFirstSeenClawChatProfiles } from "./profile-sync.ts";
|
|
48
48
|
import { pullGroupMetadata, pullOwnerMetadata } from "./clawchat-metadata.ts";
|
|
49
|
+
import { deleteClawChatMemoryFile } from "./clawchat-memory.ts";
|
|
49
50
|
import {
|
|
50
51
|
clearClawChatPromptInjectionForSession,
|
|
51
52
|
stageClawChatPromptInjection,
|
|
@@ -243,7 +244,8 @@ function optionalNullableString(record: Record<string, unknown>, key: string): s
|
|
|
243
244
|
function isConversationNotFoundError(err: unknown): boolean {
|
|
244
245
|
if (!(err instanceof ClawlingApiError)) return false;
|
|
245
246
|
return err.meta?.status === 404 || err.meta?.status === 410 ||
|
|
246
|
-
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401
|
|
247
|
+
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401 ||
|
|
248
|
+
err.message.toLowerCase().includes("conversation not found");
|
|
247
249
|
}
|
|
248
250
|
|
|
249
251
|
function metadataVersionFromEnvelope(env: Envelope): number | undefined {
|
|
@@ -477,6 +479,18 @@ export async function startOpenclawClawlingGateway(params: StartGatewayParams):
|
|
|
477
479
|
);
|
|
478
480
|
} catch (err) {
|
|
479
481
|
if (isConversationNotFoundError(err)) {
|
|
482
|
+
if (options.memoryRoot) {
|
|
483
|
+
await deleteClawChatMemoryFile(options.memoryRoot, {
|
|
484
|
+
targetType: "group",
|
|
485
|
+
targetId: conversationId,
|
|
486
|
+
}).catch((deleteError) => {
|
|
487
|
+
log?.error?.(
|
|
488
|
+
`[${accountId}] openclaw-clawchat group metadata file delete failed conversation=${conversationId}: ${
|
|
489
|
+
deleteError instanceof Error ? deleteError.message : String(deleteError)
|
|
490
|
+
}`,
|
|
491
|
+
);
|
|
492
|
+
});
|
|
493
|
+
}
|
|
480
494
|
if (store?.deleteConversationCache) {
|
|
481
495
|
recordConnection("conversation cache delete", () =>
|
|
482
496
|
store.deleteConversationCache?.({
|
package/src/tools.ts
CHANGED
|
@@ -206,7 +206,9 @@ function upsertConversationDetailsCache(
|
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
function isConversationNotFound(err: ClawlingApiError): boolean {
|
|
209
|
-
return err.meta?.status === 404 || err.meta?.
|
|
209
|
+
return err.meta?.status === 404 || err.meta?.status === 410 ||
|
|
210
|
+
err.meta?.code === 404 || err.meta?.code === 410 || err.meta?.code === 40401 ||
|
|
211
|
+
err.message.toLowerCase().includes("conversation not found");
|
|
210
212
|
}
|
|
211
213
|
|
|
212
214
|
export function registerOpenclawClawlingTools(
|