mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-11 05:20:44 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
105
openclaw/extensions/memory-wiki/src/test-helpers.ts
Normal file
105
openclaw/extensions/memory-wiki/src/test-helpers.ts
Normal file
|
|
@ -0,0 +1,105 @@
|
|||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
|
||||
import { afterEach, vi } from "vitest";
|
||||
import { createTestPluginApi } from "../../../test/helpers/plugins/plugin-api.js";
|
||||
import type { OpenClawPluginApi } from "../api.js";
|
||||
import {
|
||||
resolveMemoryWikiConfig,
|
||||
type MemoryWikiPluginConfig,
|
||||
type ResolvedMemoryWikiConfig,
|
||||
} from "./config.js";
|
||||
import { initializeMemoryWikiVault } from "./vault.js";
|
||||
|
||||
const MEMORY_WIKI_TEST_HOME = "/Users/tester";
|
||||
|
||||
export type MemoryWikiTestVault = {
|
||||
rootDir: string;
|
||||
config: ResolvedMemoryWikiConfig;
|
||||
};
|
||||
|
||||
export type MemoryWikiPluginApiHarness = {
|
||||
api: OpenClawPluginApi;
|
||||
registerCli: ReturnType<typeof vi.fn>;
|
||||
registerGatewayMethod: ReturnType<typeof vi.fn>;
|
||||
registerMemoryCorpusSupplement: ReturnType<typeof vi.fn>;
|
||||
registerMemoryPromptSupplement: ReturnType<typeof vi.fn>;
|
||||
registerTool: ReturnType<typeof vi.fn>;
|
||||
};
|
||||
|
||||
export function createMemoryWikiTestHarness() {
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(async () => {
|
||||
await Promise.all(
|
||||
tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })),
|
||||
);
|
||||
});
|
||||
|
||||
async function createTempDir(prefix: string): Promise<string> {
|
||||
const tempDir = await fs.mkdtemp(path.join(resolvePreferredOpenClawTmpDir(), prefix));
|
||||
tempDirs.push(tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
async function createVault(options?: {
|
||||
prefix?: string;
|
||||
rootDir?: string;
|
||||
config?: MemoryWikiPluginConfig;
|
||||
initialize?: boolean;
|
||||
}): Promise<MemoryWikiTestVault> {
|
||||
const rootDir =
|
||||
options?.rootDir ?? (await createTempDir(options?.prefix ?? "memory-wiki-test-"));
|
||||
const config = resolveMemoryWikiConfig(
|
||||
{
|
||||
...options?.config,
|
||||
vault: {
|
||||
...options?.config?.vault,
|
||||
path: rootDir,
|
||||
},
|
||||
},
|
||||
{ homedir: MEMORY_WIKI_TEST_HOME },
|
||||
);
|
||||
|
||||
if (options?.initialize) {
|
||||
await initializeMemoryWikiVault(config);
|
||||
}
|
||||
|
||||
return { rootDir, config };
|
||||
}
|
||||
|
||||
function createPluginApi(): MemoryWikiPluginApiHarness {
|
||||
const registerCli = vi.fn();
|
||||
const registerGatewayMethod = vi.fn();
|
||||
const registerMemoryCorpusSupplement = vi.fn();
|
||||
const registerMemoryPromptSupplement = vi.fn();
|
||||
const registerTool = vi.fn();
|
||||
const api = createTestPluginApi({
|
||||
id: "memory-wiki",
|
||||
name: "Memory Wiki",
|
||||
source: "test",
|
||||
config: {},
|
||||
runtime: {} as OpenClawPluginApi["runtime"],
|
||||
registerCli,
|
||||
registerGatewayMethod,
|
||||
registerMemoryCorpusSupplement,
|
||||
registerMemoryPromptSupplement,
|
||||
registerTool,
|
||||
});
|
||||
|
||||
return {
|
||||
api,
|
||||
registerCli,
|
||||
registerGatewayMethod,
|
||||
registerMemoryCorpusSupplement,
|
||||
registerMemoryPromptSupplement,
|
||||
registerTool,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
createPluginApi,
|
||||
createTempDir,
|
||||
createVault,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue