


























@@ -141,6 +141,10 @@ function resetMemoryRecallMocks() {
141141maybeRepairWorkspaceMemoryHealth.mockClear();
142142}
143143144+function firstNoteMessage(): string {
145+return String(note.mock.calls.at(0)?.[0] ?? "");
146+}
147+144148describe("noteMemorySearchHealth", () => {
145149const cfg = {} as OpenClawConfig;
146150@@ -209,7 +213,7 @@ describe("noteMemorySearchHealth", () => {
209213});
210214211215expect(note).toHaveBeenCalledTimes(1);
212-const message = String(note.mock.calls[0]?.[0] ?? "");
216+const message = firstNoteMessage();
213217expect(message).toContain("gateway reports local embeddings are not ready");
214218expect(message).toContain("node-llama-cpp not installed");
215219});
@@ -271,9 +275,7 @@ describe("noteMemorySearchHealth", () => {
271275expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
272276expect(checkQmdBinaryAvailability).not.toHaveBeenCalled();
273277expect(note).toHaveBeenCalledTimes(1);
274-expect(String(note.mock.calls[0]?.[0] ?? "")).toContain(
275-"No active memory plugin is registered",
276-);
278+expect(firstNoteMessage()).toContain("No active memory plugin is registered");
277279});
278280279281it("does not warn when CLI backend resolution is missing but gateway memory probe is ready", async () => {
@@ -308,9 +310,7 @@ describe("noteMemorySearchHealth", () => {
308310expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
309311expect(checkQmdBinaryAvailability).not.toHaveBeenCalled();
310312expect(note).toHaveBeenCalledTimes(1);
311-expect(String(note.mock.calls[0]?.[0] ?? "")).toContain(
312-"No active memory plugin is registered",
313-);
313+expect(firstNoteMessage()).toContain("No active memory plugin is registered");
314314});
315315316316it("warns when CLI backend resolution is missing and gateway memory probe is not ready", async () => {
@@ -328,9 +328,7 @@ describe("noteMemorySearchHealth", () => {
328328expect(resolveApiKeyForProvider).not.toHaveBeenCalled();
329329expect(checkQmdBinaryAvailability).not.toHaveBeenCalled();
330330expect(note).toHaveBeenCalledTimes(1);
331-expect(String(note.mock.calls[0]?.[0] ?? "")).toContain(
332-"No active memory plugin is registered",
333-);
331+expect(firstNoteMessage()).toContain("No active memory plugin is registered");
334332});
335333336334it("does not warn when QMD backend is active", async () => {
@@ -366,7 +364,7 @@ describe("noteMemorySearchHealth", () => {
366364await noteMemorySearchHealth(qmdCfg, {});
367365368366expect(note).toHaveBeenCalledTimes(1);
369-const message = String(note.mock.calls[0]?.[0] ?? "");
367+const message = firstNoteMessage();
370368expect(message).toContain("QMD memory backend is configured");
371369expect(message).toContain("spawn qmd ENOENT");
372370expect(message).toContain("npm install -g @tobilu/qmd");
@@ -495,7 +493,7 @@ describe("noteMemorySearchHealth", () => {
495493gatewayMemoryProbe: { checked: true, ready: false, error: "connection refused" },
496494});
497495498-const message = String(note.mock.calls[0]?.[0] ?? "");
496+const message = firstNoteMessage();
499497expect(message).toContain('provider "ollama" is configured');
500498expect(message).toContain("embeddings are not ready");
501499});
@@ -511,7 +509,7 @@ describe("noteMemorySearchHealth", () => {
511509gatewayMemoryProbe: { checked: true, ready: false, error: "LM API token missing" },
512510});
513511514-const message = String(note.mock.calls[0]?.[0] ?? "");
512+const message = firstNoteMessage();
515513expect(message).toContain('provider "lmstudio" is configured');
516514expect(message).toContain("embeddings are not ready");
517515});
@@ -569,7 +567,7 @@ describe("noteMemorySearchHealth", () => {
569567},
570568});
571569572-const message = String(note.mock.calls[0]?.[0] ?? "");
570+const message = firstNoteMessage();
573571expect(message).toContain('provider "lmstudio" is configured');
574572});
575573@@ -584,7 +582,7 @@ describe("noteMemorySearchHealth", () => {
584582gatewayMemoryProbe: { checked: true, ready: true },
585583});
586584587-const message = note.mock.calls[0]?.[0] as string;
585+const message = firstNoteMessage();
588586expect(message).toContain("reports memory embeddings are ready");
589587});
590588@@ -603,7 +601,7 @@ describe("noteMemorySearchHealth", () => {
603601},
604602});
605603606-const message = note.mock.calls[0]?.[0] as string;
604+const message = firstNoteMessage();
607605expect(message).toContain("Gateway memory probe for default agent is not ready");
608606expect(message).toContain("openclaw configure --section model");
609607expect(message).not.toContain("openclaw auth add --provider");
@@ -622,7 +620,7 @@ describe("noteMemorySearchHealth", () => {
622620// DEFAULT_LOCAL_MODEL fallback does NOT apply to auto — only to explicit
623621// provider: "local". So with no local file and no API keys, warn.
624622expect(note).toHaveBeenCalledTimes(1);
625-const message = String(note.mock.calls[0]?.[0] ?? "");
623+const message = firstNoteMessage();
626624expect(message).toContain("needs at least one embedding provider");
627625expect(message).toContain("openclaw configure --section model");
628626});
@@ -676,7 +674,7 @@ describe("noteMemorySearchHealth", () => {
676674677675await noteMemorySearchHealth(cfg);
678676679-const message = String(note.mock.calls[0]?.[0] ?? "");
677+const message = firstNoteMessage();
680678expect(message).toContain("GEMINI_API_KEY");
681679expect(message).toContain('provider is set to "gemini"');
682680});
@@ -690,7 +688,7 @@ describe("noteMemorySearchHealth", () => {
690688691689await noteMemorySearchHealth(cfg);
692690693-const message = String(note.mock.calls[0]?.[0] ?? "");
691+const message = firstNoteMessage();
694692expect(message).toContain("OPENAI_API_KEY");
695693});
696694@@ -771,7 +769,7 @@ describe("memory recall doctor integration", () => {
771769qmd: undefined,
772770});
773771expect(note).toHaveBeenCalledTimes(1);
774-const message = String(note.mock.calls[0]?.[0] ?? "");
772+const message = firstNoteMessage();
775773expect(message).toContain("Memory recall artifacts need attention:");
776774expect(message).toContain("doctor --fix");
777775expect(message).toContain("memory status --fix");
@@ -812,7 +810,7 @@ describe("memory recall doctor integration", () => {
812810workspaceDir: "/tmp/agent-default/workspace",
813811});
814812expect(note).toHaveBeenCalledTimes(1);
815-const message = String(note.mock.calls[0]?.[0] ?? "");
813+const message = firstNoteMessage();
816814expect(message).toContain("Memory recall artifacts repaired:");
817815expect(message).toContain("rewrote recall store");
818816expect(message).toContain("removed stale promotion lock");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。