mirror of https://github.com/openclaw/openclaw.git
Memory: fix QMD doctor contract typing
This commit is contained in:
parent
b33a18e280
commit
16b452040b
|
|
@ -1,6 +1,16 @@
|
|||
import type { OpenClawConfig } from "openclaw/plugin-sdk/memory-core-host-engine-foundation";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
type CheckQmdBinaryAvailability = (params: {
|
||||
command: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
cwd?: string;
|
||||
timeoutMs?: number;
|
||||
}) => Promise<{
|
||||
available: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
|
||||
function createManagerStatus(params: {
|
||||
backend: "qmd" | "builtin";
|
||||
provider: string;
|
||||
|
|
@ -95,7 +105,9 @@ const fallbackManager = vi.hoisted(() => ({
|
|||
const fallbackSearch = fallbackManager.search;
|
||||
const mockMemoryIndexGet = vi.hoisted(() => vi.fn(async () => fallbackManager));
|
||||
const mockCloseAllMemoryIndexManagers = vi.hoisted(() => vi.fn(async () => {}));
|
||||
const checkQmdBinaryAvailability = vi.hoisted(() => vi.fn(async () => ({ available: true })));
|
||||
const checkQmdBinaryAvailability = vi.hoisted(() =>
|
||||
vi.fn<CheckQmdBinaryAvailability>(async () => ({ available: true })),
|
||||
);
|
||||
|
||||
vi.mock("./qmd-manager.js", () => ({
|
||||
QmdMemoryManager: {
|
||||
|
|
|
|||
|
|
@ -2,13 +2,25 @@ import path from "node:path";
|
|||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
|
||||
type CheckQmdBinaryAvailability = (params: {
|
||||
command: string;
|
||||
env: NodeJS.ProcessEnv;
|
||||
cwd?: string;
|
||||
timeoutMs?: number;
|
||||
}) => Promise<{
|
||||
available: boolean;
|
||||
error?: string;
|
||||
}>;
|
||||
|
||||
const note = vi.hoisted(() => vi.fn());
|
||||
const resolveDefaultAgentId = vi.hoisted(() => vi.fn(() => "agent-default"));
|
||||
const resolveAgentDir = vi.hoisted(() => vi.fn(() => "/tmp/agent-default"));
|
||||
const resolveMemorySearchConfig = vi.hoisted(() => vi.fn());
|
||||
const resolveApiKeyForProvider = vi.hoisted(() => vi.fn());
|
||||
const resolveActiveMemoryBackendConfig = vi.hoisted(() => vi.fn());
|
||||
const checkQmdBinaryAvailability = vi.hoisted(() => vi.fn(async () => ({ available: true })));
|
||||
const checkQmdBinaryAvailability = vi.hoisted(() =>
|
||||
vi.fn<CheckQmdBinaryAvailability>(async () => ({ available: true })),
|
||||
);
|
||||
|
||||
vi.mock("../terminal/note.js", () => ({
|
||||
note,
|
||||
|
|
|
|||
|
|
@ -38,11 +38,19 @@ export type RegisteredMemorySearchManager = {
|
|||
close?(): Promise<void>;
|
||||
};
|
||||
|
||||
export type MemoryRuntimeBackendConfig = {
|
||||
backend: "builtin" | "qmd";
|
||||
qmd?: object;
|
||||
export type MemoryRuntimeQmdConfig = {
|
||||
command?: string;
|
||||
};
|
||||
|
||||
export type MemoryRuntimeBackendConfig =
|
||||
| {
|
||||
backend: "builtin";
|
||||
}
|
||||
| {
|
||||
backend: "qmd";
|
||||
qmd?: MemoryRuntimeQmdConfig;
|
||||
};
|
||||
|
||||
export type MemoryPluginRuntime = {
|
||||
getMemorySearchManager(params: {
|
||||
cfg: OpenClawConfig;
|
||||
|
|
|
|||
Loading…
Reference in New Issue