Files
openclaw/extensions/memory-core/src/tools.test-helpers.ts
Andy Ye ddacb7ba39 fix(memory): keep memory_search in transient qmd mode (#92639)
Summary:
- Merged fix(memory): keep memory_search in transient qmd mode after ClawSweeper review.

Automerge notes:
- PR branch already contained follow-up commit before automerge: fix(memory): close transient search managers
- PR branch already contained follow-up commit before automerge: fix(memory): preserve default search managers
- PR branch already contained follow-up commit before automerge: fix(memory): preserve qmd cli boot freshness

Validation:
- ClawSweeper review passed for head 64fe82c24c.
- Required merge gates passed before the squash merge.

Prepared head SHA: 64fe82c24c
Review: https://github.com/openclaw/openclaw/pull/92639#issuecomment-4698763950

Co-authored-by: Andy Ye <35905412+TurboTheTurtle@users.noreply.github.com>
Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com>
Approved-by: takhoffman
Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
2026-06-13 14:14:54 +00:00

74 lines
2.0 KiB
TypeScript

// Memory Core helper module supports tools helpers behavior.
import { expect } from "vitest";
import type { OpenClawConfig } from "../api.js";
import { createMemoryGetTool, createMemorySearchTool } from "./tools.js";
export function asOpenClawConfig(config: Partial<OpenClawConfig>): OpenClawConfig {
return config;
}
export function createDefaultMemoryToolConfig(): OpenClawConfig {
return asOpenClawConfig({ agents: { list: [{ id: "main", default: true }] } });
}
export function createMemorySearchToolOrThrow(params?: {
config?: OpenClawConfig;
agentId?: string;
agentSessionKey?: string;
oneShotCliRun?: boolean;
}) {
const tool = createMemorySearchTool({
config: params?.config ?? createDefaultMemoryToolConfig(),
...(params?.agentId ? { agentId: params.agentId } : {}),
...(params?.agentSessionKey ? { agentSessionKey: params.agentSessionKey } : {}),
...(params?.oneShotCliRun ? { oneShotCliRun: params.oneShotCliRun } : {}),
});
if (!tool) {
throw new Error("tool missing");
}
return tool;
}
export function createMemoryGetToolOrThrow(
config: OpenClawConfig = createDefaultMemoryToolConfig(),
) {
const tool = createMemoryGetTool({ config });
if (!tool) {
throw new Error("tool missing");
}
return tool;
}
export function createAutoCitationsMemorySearchTool(agentSessionKey: string) {
return createMemorySearchToolOrThrow({
config: asOpenClawConfig({
memory: { citations: "auto" },
agents: { list: [{ id: "main", default: true }] },
}),
agentSessionKey,
});
}
export function expectUnavailableMemorySearchDetails(
details: unknown,
params: {
error: string;
warning: string;
action: string;
},
) {
expect(details).toEqual({
results: [],
disabled: true,
unavailable: true,
error: params.error,
warning: params.warning,
action: params.action,
debug: {
warning: params.warning,
action: params.action,
error: params.error,
},
});
}