

























@@ -29,6 +29,25 @@ const MEMORY_EMBEDDING_PROVIDERS_KEY = Symbol.for("openclaw.memoryEmbeddingProvi
2929const MCPORTER_STATE_KEY = Symbol.for("openclaw.mcporterState");
3030const QMD_EMBED_QUEUE_KEY = Symbol.for("openclaw.qmdEmbedQueueTail");
313132+type WatchOptions = {
33+ignored?: (watchPath: string) => boolean;
34+};
35+36+type EmbedLockCall = [
37+string,
38+{
39+retries: {
40+retries: number;
41+factor: number;
42+minTimeout: number;
43+maxTimeout: number;
44+randomize: boolean;
45+};
46+stale: number;
47+},
48+() => Promise<unknown>,
49+];
50+3251interface MockChild extends EventEmitter {
3352stdout: EventEmitter;
3453stderr: EventEmitter;
@@ -83,6 +102,22 @@ function isMcporterCommand(cmd: unknown): boolean {
83102return /(^|[\\/])mcporter(?:\.cmd)?$/i.test(cmd);
84103}
85104105+function firstWatchOptions(): WatchOptions {
106+const call = watchMock.mock.calls[0] as unknown as [string[], WatchOptions] | undefined;
107+if (!call) {
108+throw new Error("Expected watch call");
109+}
110+return call[1];
111+}
112+113+function firstEmbedLockCall(): EmbedLockCall {
114+const call = withFileLockMock.mock.calls[0] as EmbedLockCall | undefined;
115+if (!call) {
116+throw new Error("Expected qmd embed lock call");
117+}
118+return call;
119+}
120+86121vi.mock("openclaw/plugin-sdk/memory-core-host-engine-foundation", async () => {
87122const actual = await vi.importActual<
88123typeof import("openclaw/plugin-sdk/memory-core-host-engine-foundation")
@@ -457,10 +492,7 @@ describe("QmdMemoryManager", () => {
457492};
458493const initialUpdateCalls = spawnMock.mock.calls.filter((call) => call[1]?.[0] === "update");
459494expect(initialUpdateCalls).toHaveLength(0);
460-const [, watchOptions] = watchMock.mock.calls.at(0) as unknown as [
461-string[],
462-{ ignored?: (watchPath: string) => boolean },
463-];
495+const watchOptions = firstWatchOptions();
464496expect(watchOptions.ignored?.(path.join(workspaceDir, "node_modules", "pkg", "note.md"))).toBe(
465497true,
466498);
@@ -3719,26 +3751,7 @@ describe("QmdMemoryManager", () => {
37193751const firstSync = first.manager.sync({ reason: "manual", force: true });
37203752await vi.advanceTimersByTimeAsync(0);
37213753expect(embedChildren).toHaveLength(1);
3722-const lockCall = withFileLockMock.mock.calls.at(0) as
3723-| [
3724-string,
3725-{
3726-retries: {
3727-retries: number;
3728-factor: number;
3729-minTimeout: number;
3730-maxTimeout: number;
3731-randomize: boolean;
3732-};
3733-stale: number;
3734-},
3735-() => Promise<unknown>,
3736-]
3737-| undefined;
3738-if (!lockCall) {
3739-throw new Error("Expected qmd embed lock call");
3740-}
3741-const [lockPath, lockOptions, lockTask] = lockCall;
3754+const [lockPath, lockOptions, lockTask] = firstEmbedLockCall();
37423755expect(lockPath.endsWith(path.join("qmd", "embed.lock"))).toBe(true);
37433756expect(lockOptions).toEqual({
37443757retries: {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。