mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 21:30:45 +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
82
openclaw/test/scripts/runtime-postbuild.test.ts
Normal file
82
openclaw/test/scripts/runtime-postbuild.test.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
copyStaticExtensionAssets,
|
||||
listStaticExtensionAssetOutputs,
|
||||
writeStableRootRuntimeAliases,
|
||||
} from "../../scripts/runtime-postbuild.mjs";
|
||||
import { createScriptTestHarness } from "./test-helpers.js";
|
||||
|
||||
const { createTempDir } = createScriptTestHarness();
|
||||
|
||||
describe("runtime postbuild static assets", () => {
|
||||
it("tracks plugin-owned static assets that release packaging must ship", () => {
|
||||
expect(listStaticExtensionAssetOutputs()).toContain(
|
||||
"dist/extensions/diffs/assets/viewer-runtime.js",
|
||||
);
|
||||
});
|
||||
|
||||
it("copies declared static assets into dist", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const src = "extensions/acpx/src/runtime-internals/mcp-proxy.mjs";
|
||||
const dest = "dist/extensions/acpx/mcp-proxy.mjs";
|
||||
const sourcePath = path.join(rootDir, src);
|
||||
const destPath = path.join(rootDir, dest);
|
||||
await fs.mkdir(path.dirname(sourcePath), { recursive: true });
|
||||
await fs.writeFile(sourcePath, "proxy-data\n", "utf8");
|
||||
|
||||
copyStaticExtensionAssets({
|
||||
rootDir,
|
||||
assets: [{ src, dest }],
|
||||
});
|
||||
|
||||
expect(await fs.readFile(destPath, "utf8")).toBe("proxy-data\n");
|
||||
});
|
||||
|
||||
it("warns when a declared static asset is missing", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const warn = vi.fn();
|
||||
|
||||
copyStaticExtensionAssets({
|
||||
rootDir,
|
||||
assets: [{ src: "missing/file.mjs", dest: "dist/file.mjs" }],
|
||||
warn,
|
||||
});
|
||||
|
||||
expect(warn).toHaveBeenCalledWith(
|
||||
"[runtime-postbuild] static asset not found, skipping: missing/file.mjs",
|
||||
);
|
||||
});
|
||||
|
||||
it("writes stable aliases for hashed root runtime modules", async () => {
|
||||
const rootDir = createTempDir("openclaw-runtime-postbuild-");
|
||||
const distDir = path.join(rootDir, "dist");
|
||||
await fs.mkdir(distDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "runtime-model-auth.runtime-XyZ987.js"),
|
||||
"export const auth = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "runtime-tts.runtime-AbCd1234.js"),
|
||||
"export const tts = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
await fs.writeFile(
|
||||
path.join(distDir, "library-Other123.js"),
|
||||
"export const x = true;\n",
|
||||
"utf8",
|
||||
);
|
||||
|
||||
writeStableRootRuntimeAliases({ rootDir });
|
||||
|
||||
expect(await fs.readFile(path.join(distDir, "runtime-model-auth.runtime.js"), "utf8")).toBe(
|
||||
'export * from "./runtime-model-auth.runtime-XyZ987.js";\n',
|
||||
);
|
||||
expect(await fs.readFile(path.join(distDir, "runtime-tts.runtime.js"), "utf8")).toBe(
|
||||
'export * from "./runtime-tts.runtime-AbCd1234.js";\n',
|
||||
);
|
||||
await expect(fs.stat(path.join(distDir, "library.js"))).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue