mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:30:42 +00:00
QA: replace qa-lab-runtime with qa-runtime
Introduce a tiny generic qa-runtime seam for shared live-lane helpers and repoint qa-matrix to it. This keeps the qa-lab host split while removing the host-owned runtime name from runner code. Drop the old qa-lab-runtime shim/export now that nothing consumes it and keep the plugin-sdk surface aligned with the new seam.
This commit is contained in:
47
src/plugin-sdk/qa-runtime.test.ts
Normal file
47
src/plugin-sdk/qa-runtime.test.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const loadBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock("./facade-runtime.js", () => ({
|
||||
loadBundledPluginPublicSurfaceModuleSync,
|
||||
}));
|
||||
|
||||
describe("plugin-sdk qa-runtime", () => {
|
||||
beforeEach(() => {
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockReset();
|
||||
});
|
||||
|
||||
it("stays cold until the runtime seam is used", async () => {
|
||||
const module = await import("./qa-runtime.js");
|
||||
|
||||
expect(loadBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
|
||||
expect(typeof module.loadQaRuntimeModule).toBe("function");
|
||||
expect(typeof module.isQaRuntimeAvailable).toBe("function");
|
||||
});
|
||||
|
||||
it("loads the qa-lab runtime public surface through the generic seam", async () => {
|
||||
const runtimeSurface = {
|
||||
defaultQaRuntimeModelForMode: vi.fn(),
|
||||
startQaLiveLaneGateway: vi.fn(),
|
||||
};
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockReturnValue(runtimeSurface);
|
||||
|
||||
const module = await import("./qa-runtime.js");
|
||||
|
||||
expect(module.loadQaRuntimeModule()).toBe(runtimeSurface);
|
||||
expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({
|
||||
dirName: "qa-lab",
|
||||
artifactBasename: "runtime-api.js",
|
||||
});
|
||||
});
|
||||
|
||||
it("reports the runtime as unavailable when the qa-lab surface is missing", async () => {
|
||||
loadBundledPluginPublicSurfaceModuleSync.mockImplementation(() => {
|
||||
throw new Error("Unable to resolve bundled plugin public surface qa-lab/runtime-api.js");
|
||||
});
|
||||
|
||||
const module = await import("./qa-runtime.js");
|
||||
|
||||
expect(module.isQaRuntimeAvailable()).toBe(false);
|
||||
});
|
||||
});
|
||||
39
src/plugin-sdk/qa-runtime.ts
Normal file
39
src/plugin-sdk/qa-runtime.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { loadBundledPluginPublicSurfaceModuleSync } from "./facade-runtime.js";
|
||||
|
||||
type QaRuntimeSurface = {
|
||||
defaultQaRuntimeModelForMode: (
|
||||
mode: string,
|
||||
options?: {
|
||||
alternate?: boolean;
|
||||
preferredLiveModel?: string;
|
||||
},
|
||||
) => string;
|
||||
startQaLiveLaneGateway: (...args: unknown[]) => Promise<unknown>;
|
||||
};
|
||||
|
||||
function isMissingQaRuntimeError(error: unknown) {
|
||||
return (
|
||||
error instanceof Error &&
|
||||
(error.message === "Unable to resolve bundled plugin public surface qa-lab/runtime-api.js" ||
|
||||
error.message.startsWith("Unable to open bundled plugin public surface "))
|
||||
);
|
||||
}
|
||||
|
||||
export function loadQaRuntimeModule(): QaRuntimeSurface {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<QaRuntimeSurface>({
|
||||
dirName: "qa-lab",
|
||||
artifactBasename: "runtime-api.js",
|
||||
});
|
||||
}
|
||||
|
||||
export function isQaRuntimeAvailable(): boolean {
|
||||
try {
|
||||
loadQaRuntimeModule();
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (isMissingQaRuntimeError(error)) {
|
||||
return false;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user