Skip to content

Commit 943cb47

Browse files
committed
fix(qa): use exported runner sdk seam
1 parent 4caa882 commit 943cb47

5 files changed

Lines changed: 70 additions & 3 deletions

File tree

extensions/qa-matrix/src/runners/contract/model-selection.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
33
const loadQaRuntimeModule = vi.hoisted(() => vi.fn());
44
const defaultQaRuntimeModelForMode = vi.hoisted(() => vi.fn());
55

6-
vi.mock("openclaw/plugin-sdk/qa-runtime", () => ({
6+
vi.mock("openclaw/plugin-sdk/qa-runner-runtime", () => ({
77
loadQaRuntimeModule,
88
}));
99

extensions/qa-matrix/src/runners/contract/model-selection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { loadQaRuntimeModule } from "openclaw/plugin-sdk/qa-runtime";
1+
import { loadQaRuntimeModule } from "openclaw/plugin-sdk/qa-runner-runtime";
22
import { normalizeQaProviderMode, type QaProviderModeInput } from "../../run-config.js";
33

44
export type ResolvedMatrixQaModels = {

extensions/qa-matrix/src/runners/contract/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import path from "node:path";
44
import { setTimeout as sleep } from "node:timers/promises";
55
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
66
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
7-
import { loadQaRuntimeModule } from "openclaw/plugin-sdk/qa-runtime";
7+
import { loadQaRuntimeModule } from "openclaw/plugin-sdk/qa-runner-runtime";
88
import type { QaReportCheck } from "../../report.js";
99
import { renderQaMarkdownReport } from "../../report.js";
1010
import { type QaProviderModeInput } from "../../run-config.js";

src/plugin-sdk/qa-runner-runtime.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ describe("plugin-sdk qa-runner-runtime", () => {
3232
expect(tryLoadActivatedBundledPluginPublicSurfaceModuleSync).not.toHaveBeenCalled();
3333
});
3434

35+
it("loads the qa-lab runtime public surface through the public runner seam", async () => {
36+
const runtimeSurface = {
37+
defaultQaRuntimeModelForMode: vi.fn(),
38+
startQaLiveLaneGateway: vi.fn(),
39+
};
40+
loadBundledPluginPublicSurfaceModuleSync.mockReturnValue(runtimeSurface);
41+
42+
const module = await import("./qa-runner-runtime.js");
43+
44+
expect(module.loadQaRuntimeModule()).toBe(runtimeSurface);
45+
expect(loadBundledPluginPublicSurfaceModuleSync).toHaveBeenCalledWith({
46+
dirName: "qa-lab",
47+
artifactBasename: "runtime-api.js",
48+
});
49+
});
50+
51+
it("reports the qa runtime as unavailable when the qa-lab surface is missing", async () => {
52+
loadBundledPluginPublicSurfaceModuleSync.mockImplementation(() => {
53+
throw new Error("Unable to resolve bundled plugin public surface qa-lab/runtime-api.js");
54+
});
55+
56+
const module = await import("./qa-runner-runtime.js");
57+
58+
expect(module.isQaRuntimeAvailable()).toBe(false);
59+
});
60+
3561
it("returns activated runner registrations declared in plugin manifests", async () => {
3662
const register = vi.fn((qa: Command) => qa);
3763
loadPluginManifestRegistry.mockReturnValue({

src/plugin-sdk/qa-runner-runtime.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ type QaRunnerRuntimeSurface = {
1515
qaRunnerCliRegistrations?: readonly QaRunnerCliRegistration[];
1616
};
1717

18+
type QaRuntimeSurface = {
19+
defaultQaRuntimeModelForMode: (
20+
mode: string,
21+
options?: {
22+
alternate?: boolean;
23+
preferredLiveModel?: string;
24+
},
25+
) => string;
26+
startQaLiveLaneGateway: (...args: unknown[]) => Promise<unknown>;
27+
};
28+
1829
export type QaRunnerCliContribution =
1930
| {
2031
pluginId: string;
@@ -30,6 +41,36 @@ export type QaRunnerCliContribution =
3041
status: "blocked";
3142
};
3243

44+
function isMissingQaRuntimeError(error: unknown) {
45+
if (!(error instanceof Error)) {
46+
return false;
47+
}
48+
return (
49+
error.message.includes("qa-lab") &&
50+
(error.message.includes("runtime-api.js") ||
51+
error.message.startsWith("Unable to open bundled plugin public surface "))
52+
);
53+
}
54+
55+
export function loadQaRuntimeModule(): QaRuntimeSurface {
56+
return loadBundledPluginPublicSurfaceModuleSync<QaRuntimeSurface>({
57+
dirName: ["qa", "lab"].join("-"),
58+
artifactBasename: ["runtime-api", "js"].join("."),
59+
});
60+
}
61+
62+
export function isQaRuntimeAvailable(): boolean {
63+
try {
64+
loadQaRuntimeModule();
65+
return true;
66+
} catch (error) {
67+
if (isMissingQaRuntimeError(error)) {
68+
return false;
69+
}
70+
throw error;
71+
}
72+
}
73+
3374
function listDeclaredQaRunnerPlugins(): Array<
3475
PluginManifestRecord & {
3576
qaRunners: NonNullable<PluginManifestRecord["qaRunners"]>;

0 commit comments

Comments
 (0)